app/models/passage.rb
def save_image_passage(artifact, crop)
      Tempfile.open("image_passage") do |f|
        f.binmode
        f.write(artifact.file.download)
        f.rewind
        crop_image(f.path, crop)
        file.attach(io:           f,
                    filename:     artifact.file.filename,
                    content_type: artifact.file.content_type)
      end
    end
##
# attaches the image of the artifact to the passage,
# which is cropped to the input values
# @param artifact [Artifact] the artifact with the original Image
# @param crop [String] the crop value in String format
#   (width*height+start_x+start_y)
attaches the image of the artifact to the passage,
which is cropped to the input values
attaches the image of the artifact to the passage which is cropped to the input values
def save_image_passage(artifact, crop)
      Tempfile.open("image_passage") do |f|
        f.binmode
        f.write(artifact.file.download)
        f.rewind
        crop_image(f.path, crop)
        file.attach(io:           f,
                    filename:     artifact.file.filename,
                    content_type: artifact.file.content_type)
      end
    end
def save_image_passage ( artifact , crop ) Tempfile . open ( "image_passage" ) do | f | f . binmode f . write ( artifact . file . download ) f . rewind crop_image ( f . path , crop ) file . attach ( io : f , filename : artifact . file . filename , content_type : artifact . file . content_type ) end end
attaches the image of the artifact to the passage,
which is cropped to the input values
attaches the image of the artifact to the passage which is cropped to the input values
artifact
the artifact with the original Image
the artifact with the original Image
crop
the crop value in String format (width*height+start_x+start_y)
the crop value in String format ( width * height + start_x + start_y )