ruby on rails - Carrierwave and Jcrop not cropping with Minimagick -


i'm following ryan bates tutorial on how crop images carrierwave , jcrop.

but, images not being cropped. x,y,w,h values being passed in parameters, no cropping taking place. im using minimagick. appreciate someone.

i've followed similar issues in stackoverflow none give solution. thank you

photo_uploader

  process :resize_to_fit => [800,800]    version :big     process :resize_to_limit => [800,600]     process :convert => 'jpg'   end    version :thumb, :from_version => :big     process :crop     resize_to_fill(100,100)   end    def crop     if model.crop_x.present?       resize_to_limit(600, 600)       manipulate! |img|         x = model.crop_x.to_i         y = model.crop_y.to_i         w = model.crop_w.to_i         h = model.crop_h.to_i         img.crop "#{model.crop_x}x#{model.crop_y}+#{model.crop_w}+#{model.crop_h}"         img       end     end   end 

view

<%= image_tag @photo.photo_url(:big), id: "cropbox" %> 

model

  mount_uploader :photo, photouploader   attr_accessor :crop_x, :crop_y, :crop_w, :crop_h   before_create :crop_spot   after_update :crop_spot 

update

#cropping spots def crop_spot   photo.recreate_versions! if crop_x.present? end 

the img.crop method not change image, returns new one. either use img.crop!, edits image in place, or remove last img, edited image retured.

the crop method becomes

def crop   if model.crop_x.present?     resize_to_limit(600, 600)     manipulate! |img|       x = model.crop_x.to_i       y = model.crop_y.to_i       w = model.crop_w.to_i       h = model.crop_h.to_i       img.crop "#{model.crop_x}x#{model.crop_y}+#{model.crop_w}+#{model.crop_h}"     end   end end 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -