Minimagick resize image

2

I'm trying to make a crop with minimagick in Rails and something strange is happening.

The code is as follows:

def resize_crop
    manipulate! do |img|
      img.resize model.width
    end
    # resize_to_fill model.width, 0
  end

The first time I call the function that resizes the image, it returns the following error:

  

ActiveRecord :: RecordInvalid: Validation failed: Crop Failed to   manipulate with MiniMagick, maybe it is not an image? Original Error:    identify /tmp/mini_magick20170111-8437-12evsch.jpeg failed with   error: identify.im6: Not a JPEG file: starts with 0x23 0

Instead, the next time it runs correctly. I have tried to disable the validation of minimagick, but I see that the problem comes from mogrify.

Any suggestions to solve this behavior?

    
asked by Victorio Iglesias 14.03.2017 в 21:35
source

1 answer

0

You did not think about generating a better thumb? if you decide to resize that way I recommend you go to the photouploader app / uploaders / photouploaders driver inside that place there is a commented place:   # Create different versions of your uploaded files:   here take out # -version: thumb do      here take out # -process resize_to_fill: [100, 100]    here take out # -end in that way where the parameters are you can decide how soon to leave the resize, then when you do the the image tag <% = image_tag (parametro.img.thumb)% > flames when resize add the .thumb and you will have your image in fixed format

    
answered by 17.03.2017 в 01:17