File_column and animated gifs


#1

hi,

is it possible to resize animated gifs with file_column?
if i upload an animated gif file with file_column than the animation no
longer exists…


#2

Hi folks,

I just started getting this error all of a sudden (command line
snippet):

vmac:~/workspace/eir vince$ ruby -v
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
vmac:~/workspace/eir vince$ rails -v
Rails 1.0.0
vmac:~/workspace/eir vince$ gem -v
0.8.11
vmac:~/workspace/eir vince$ ./script/server
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
require__': No such file to load -- initializer (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
from ./script/…/config/boot.rb:16
from ./script/server:2:in `require’
from ./script/server:2
vmac:~/workspace/eir vince$

Is anybody else having the same issue? Any clues as to what may be
wrong?
I did nothing to my environment, but the problem started after Mac OS X
notified me that updates were available and I started them in the
back-ground.


#3

These instructions seem to have fixed the problem:
http://www.tonyarnold.com/articles/2005/08/10/rolling-with-ruby-on-rails-on-
mac-os-x-tiger-for-beginners


#4

Yes, but you may have to tinker around with RMagick/imagemagick. I
would guess that your image is being split into its component frames
as its being resized, and the command to merge the frames back into an
animation is not being given. So that’s a bug you’ll have to get
past, but then it should work.

-Kyle


#5

Kyle M. wrote:

Yes, but you may have to tinker around with RMagick/imagemagick. I
would guess that your image is being split into its component frames
as its being resized, and the command to merge the frames back into an
animation is not being given. So that’s a bug you’ll have to get
past, but then it should work.

-Kyle

thanks for reply kyle

now i just use Magick::ImageList instead of Magick::Image and it seems
to work
so the class BaseUploadedFile looks something like this:

class BaseUploadedFile # :nodoc:
def transform_with_magick
if needs_resize?
begin
imglist = ::Magick::ImageList.new(absolute_path)
rescue ::Magick::ImageMagickError
@magick_errors ||= []
@magick_errors << “invalid image”
return
end

    ...

  end
end

...

def resize_image(imglist, img_options, dest_path)
  begin
    if img_options[:crop]
      dx, dy = img_options[:crop].split(':').map { |x| x.to_f }
      w, h = (imglist.first.rows * dx / dy), (imglist.first.columns 
  • dy / dx)
    imglist.each do |img|
    img.crop!(::Magick::CenterGravity, [img.columns, w].min,
    [img.rows, h].min)
    end
    end

      if img_options[:size]
        size = img_options[:size].split("x")
        xres = imglist.first.columns
        yres = imglist.first.rows
        if xres > size[0].to_i || yres > size[1].to_i
          imglist.each do |img|
            img.change_geometry!(img_options[:size]) do |c, r, i|
              i.resize!(c, r)
            end
          end
        end
      end
    ensure
      imglist.write dest_path
      File.chmod options[:permissions], dest_path
    end
    

    end
    end