Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Adding the ability to do two cropping #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/rails_admin_jcrop/asset_engine/paperclip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,18 @@ def transformation_command
if @attachment.instance.rails_admin_cropping?
ary = super
if i = ary.index('-crop')
ary_original = ary.dup
ary.delete_at i+1
ary.delete_at i

params = (['-crop', crop_params] + ary).join(' ')
style_name = @attachment.styles.keys[@attachment.styles.values.map(&:geometry).index(@target_geometry.to_s)]
image = @attachment.instance.send(@attachment.name).path(style_name)

system "convert '#{@file.path}' #{params} '#{image}'"
return ary_original
end

['-crop', crop_params] + ary
else
super
Expand Down