image scaling
This commit is contained in:
parent
d50d075a98
commit
02c202fcd3
@ -1,3 +1,5 @@
|
||||
require "mini_magick"
|
||||
|
||||
module Merged
|
||||
|
||||
class ImagesController < MergedController
|
||||
@ -19,9 +21,24 @@ module Merged
|
||||
def destroy
|
||||
@image = Image.find(params[:id])
|
||||
@image.destroy
|
||||
redirect_to :images , nootice: "Image #{@image.name} deleted"
|
||||
redirect_to :images , notice: "Image #{@image.name} deleted"
|
||||
end
|
||||
|
||||
def update
|
||||
@image = Image.find(params[:id])
|
||||
mini = MiniMagick::Image.new( @image.full_filename)
|
||||
if(params[:scale])
|
||||
message = "Image was scaled"
|
||||
mini.resize( "#{params[:scale]}%")
|
||||
else
|
||||
mini.resize( "#{new_width}x#{new_height}+#{x_offset}+#{y_offset}")
|
||||
# x offset to the right
|
||||
# y offset from top down
|
||||
end
|
||||
@image.edit_save(current_member.email)
|
||||
@image.init_file_data
|
||||
redirect_to image_path , notice: message
|
||||
end
|
||||
def show
|
||||
@image = Image.find(params[:id])
|
||||
@sections = Section.where(image_id: params[:id].to_i)
|
||||
|
@ -3,8 +3,12 @@
|
||||
|
||||
%section.image
|
||||
.flex.justify-center
|
||||
%range-slider.justify-self-start{"v-model":"scale" , ":min":0, ":max":100 ,
|
||||
":step": "1"} Scale {{scaled_x}} x {{scaled_y}} == {{scale}} %
|
||||
= form_tag( merged.image_path , {method: :patch } ) do
|
||||
%input{ hidden: true , id: :scale_id , name: :scale , "v-bind:value": "scale" }
|
||||
%button.mt-3.bg-cyan-200{class: button_classes , name: :type , value: 'scale'} Scale {{scale}} %
|
||||
|
||||
%range-slider.mx-20.justify-self-start{"v-model":"scale" , ":min":20, ":max":100 ,
|
||||
":step": "0.1"} Scale {{scaled_x}} x {{scaled_y}}
|
||||
.flex.justify-between
|
||||
%range-slider.justify-self-start.horizontal{"v-model":"off_y" , ":min":0, ":max":"size_y" ,
|
||||
":step": "1"} Y Offset {{off_y}}
|
||||
@ -32,6 +36,9 @@
|
||||
@size_x = @image_data[:width]
|
||||
@size_y = @image_data[:height]
|
||||
end
|
||||
def scole(ignored)
|
||||
return @scale
|
||||
end
|
||||
def scaled_x
|
||||
(@initial_x * @scale / 100).to_i
|
||||
end
|
||||
|
@ -61,5 +61,5 @@
|
||||
|
||||
:css
|
||||
.horizontal input {
|
||||
transform:rotate(270deg);
|
||||
transform:rotate(90deg);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user