dans cette méthode je lis une image
que je transforme en format 60x60, puis en 120x120
et finalement en plus je la sauvegarde dans un autre repertoire
En rouge c'est ce qu'ai rajouté pour avoir une trace
ou pour changer la façon de procéder
mais rien n'y fait
def valid60x60
puts ">>>>>>>>>>>>valid60x60 begin begin begin <<<<<<<<<<<"
require 'rubygems'
require 'RMagick'
# include Magick
# il faut récupérer le fileName !!!!!!!!!!!!!!!!!!!!!!!!!
# et en 2 parties
@mode = "U"
iid = params[:id]
source = params[:s]
puts ">>>>>>>>>>>>>>ON EST LA <<<<<<<<<<<<<<<<<<<<<" + source
@expo = Expo.find(iid)
input = File.join("public", "images", source)
input.downcase
puts input
dir = File.join("public", "images") # pas toucher
targ = File.join(dir, @expo.auth)
typsrc =@expo.typsrc
typsrc.downcase
if typsrc == "jpg"
typf = "jpg"
else
typf = "png"
end
fout = @expo.file + "." + typf
dim1 = "#{60}x#{60}"
dim2 = "#{120}x#{120}"
dim3 = "#{960}x#{960}"
# FORMAT 60
model = Magick::Image::read(input)[0]
photo = model
photo.change_geometry!(dim1){|cols, rows| model.thumbnail! cols, rows}
output = File.join(targ, "ima60", fout)
puts "copying to " + output + " $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" photo.write(output)
rescue
puts "Caught exception: #{$!}"
jusque là tout marche très bien
et je retrouve bien mon image en format 60x60
là où j'attends qu'elle soit
photo.remove
GC.start
Ensuite plus rien ne marche
pas de message
pas de plantage
et je me retrouve sur mon panel valid60x60.html.erb
voir à la fin de la méthode
# FORMAT 120
photo = model
photo.change_geometry!(dim2){|cols, rows| model.thumbnail! cols, rows}
output = File.join(targ, "ima120", fout)
puts "copying to " + output + " $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"
photo.write(output)
rescue
puts "Caught exception: #{$!}"
photo.remove# under otor
# FORMAT big
photo = model
photo.change_geometry!(dim3){|cols, rows| model.thumbnail! cols, rows}
output = File.join(targ, fout)
puts "copying to " + output + " $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"
photo.write(output)
rescue
puts "Caught exception: #{$!}"
# sauvegarde SOURCE big/otor
photo = model
targbig = File.join(dir, "big", @expo.auth)
finp = @expo.file + "." + typsrc
finp.downcase
output = File.join(targbig, finp)
puts "copying to " + output + " $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"
photo.write(output)
rescue
puts "Caught exception: #{$!}"
redirect_to :controller => "validate"
end
Quelqu'un aurait-il la bonté
d'avoir une bonne idée ?
Partager