resize, or cropping, with offsets
This commit is contained in:
parent
0cab5f5523
commit
c791ee9f3c
@ -31,9 +31,10 @@ module Merged
|
|||||||
message = "Image was scaled"
|
message = "Image was scaled"
|
||||||
mini.resize( "#{params[:scale]}%")
|
mini.resize( "#{params[:scale]}%")
|
||||||
else
|
else
|
||||||
mini.resize( "#{new_width}x#{new_height}+#{x_offset}+#{y_offset}")
|
size = "#{params[:size_x]}x#{params[:size_y]}+#{params[:off_x]}+#{params[:off_y]}"
|
||||||
# x offset to the right
|
puts size
|
||||||
# y offset from top down
|
mini.crop( size )
|
||||||
|
message = "Image was resized"
|
||||||
end
|
end
|
||||||
@image.edit_save(current_member.email)
|
@image.edit_save(current_member.email)
|
||||||
@image.init_file_data
|
@image.init_file_data
|
||||||
|
@ -9,6 +9,16 @@
|
|||||||
|
|
||||||
%range-slider.mx-20.justify-self-start{"v-model":"scale" , ":min":20, ":max":100 ,
|
%range-slider.mx-20.justify-self-start{"v-model":"scale" , ":min":20, ":max":100 ,
|
||||||
":step": "0.1"} Scale {{scaled_x}} x {{scaled_y}}
|
":step": "0.1"} Scale {{scaled_x}} x {{scaled_y}}
|
||||||
|
|
||||||
|
= form_tag( merged.image_path , {method: :patch } ) do
|
||||||
|
%input{ hidden: true , id: :width_id , name: :size_x , "v-bind:value": "size_x" }
|
||||||
|
%input{ hidden: true , id: :height_id , name: :size_y , "v-bind:value": "size_y" }
|
||||||
|
%input{ hidden: true , id: :off_x_id , name: :off_x , "v-bind:value": "off_x" }
|
||||||
|
%input{ hidden: true , id: :off_y_id , name: :off_y , "v-bind:value": "off_y" }
|
||||||
|
%button.mt-3.bg-cyan-200{class: button_classes , name: :type , value: 'resize'} Resize
|
||||||
|
|
||||||
|
%label Ratio {{ratio}} : 1
|
||||||
|
|
||||||
.flex.justify-between
|
.flex.justify-between
|
||||||
%range-slider.justify-self-start.horizontal{"v-model":"off_y" , ":min":0, ":max":"size_y" ,
|
%range-slider.justify-self-start.horizontal{"v-model":"off_y" , ":min":0, ":max":"size_y" ,
|
||||||
":step": "1"} Y Offset {{off_y}}
|
":step": "1"} Y Offset {{off_y}}
|
||||||
@ -36,8 +46,8 @@
|
|||||||
@size_x = @image_data[:width]
|
@size_x = @image_data[:width]
|
||||||
@size_y = @image_data[:height]
|
@size_y = @image_data[:height]
|
||||||
end
|
end
|
||||||
def scole(ignored)
|
def ratio
|
||||||
return @scale
|
((@size_x / @size_y)*100).to_i / 100
|
||||||
end
|
end
|
||||||
def scaled_x
|
def scaled_x
|
||||||
(@initial_x * @scale / 100).to_i
|
(@initial_x * @scale / 100).to_i
|
||||||
|
Loading…
Reference in New Issue
Block a user