Forum: Ruby on Rails file_column and animated gifs

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
681841264a2d1bc716fe1cc862276ef3?d=identicon&s=25 Trung Tran (trung)
on 2006-04-07 17:42
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...
5f3d7eb9e9314f4eb94b4040cee4d8d2?d=identicon&s=25 Vince Puzzella (Guest)
on 2006-04-07 17:47
(Received via mailing list)
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:in
`require'
        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.
5f3d7eb9e9314f4eb94b4040cee4d8d2?d=identicon&s=25 Vince Puzzella (Guest)
on 2006-04-07 18:14
(Received via mailing list)
These instructions seem to have fixed the problem:
http://www.tonyarnold.com/articles/2005/08/10/roll...
mac-os-x-tiger-for-beginners
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-04-07 22:10
(Received via mailing list)
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
681841264a2d1bc716fe1cc862276ef3?d=identicon&s=25 Trung Tran (trung)
on 2006-04-07 22:37
Kyle Maxwell 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
This topic is locked and can not be replied to.