Hi all, I patched file_column to add imagemagick transformations of uploaded content. I added an options hash, and it takes the :magick and :format keys. :magick is a string of imagemagick command line options for convert (Reference: http://www.imagemagick.org/script/convert.php). Format is an optional extension for the finished image. If Imagemagick recognizes the extension, then it will convert to the appropriate format. If Imagemagick does not recognize the file as an image, then a validation will fail on the object. Example: file_column :image, :magick => "-resize 400x300", :format => ".jpg" You can also use this version to require a specific type of file to be uploaded. Again, this throws a validation error if the file does not match Examples: file_column :document, :format => ".txt" file_column :document, :format => [".doc", ".pdf"] The code is definitely alpha quality. No warranty, etc. I hope someone finds it useful. I''d definitely like some feedback on it too! Kyle Maxwell _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sebastian Kanthak
2005-Sep-19 14:15 UTC
Re: file_column: patched for imagemagick and validation
Kyle, On 9/9/05, Kyle Maxwell <kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org> wrote:> Example: > file_column :image, :magick => "-resize 400x300", :format => ".jpg"that''s pretty cool! I was thinking about integrating something like this in the future, so I might borrow some of your code if you don''t mind? Nice work Sebastian
This is a pretty cool addition to file_column, but how about allowing for the transformation to happen on the original image after its been uploaded. So it would only transform it before it is displayed, leaving the original image alone. Maybe this could be done by creating multiple versions of the image? I think integrating the ImageMagick library with file_column would be awesome! ImageMagick for Rails: http://vantulder.net/rails/magick/ On 9/9/05, Kyle Maxwell <kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org> wrote:> Hi all, > > I patched file_column to add imagemagick transformations of uploaded > content. I added an options hash, and it takes the :magick and > :format keys. :magick is a string of imagemagick command line options > for convert (Reference: > http://www.imagemagick.org/script/convert.php). Format is an optional > extension for the finished image. If Imagemagick recognizes the > extension, then it will convert to the appropriate format. If > Imagemagick does not recognize the file as an image, then a validation > will fail on the object. > > Example: > file_column :image, :magick => "-resize 400x300", :format => ".jpg" > > You can also use this version to require a specific type of file to be > uploaded. Again, this throws a validation error if the file does not > match > > Examples: > file_column :document, :format => ".txt" > file_column :document, :format => [".doc", ".pdf"] > > The code is definitely alpha quality. No warranty, etc. I hope > someone finds it useful. I''d definitely like some feedback on it too! > > > Kyle Maxwell > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-- - Ramin http://www.getintothis.com/blog
Raymond Brigleb
2005-Sep-22 00:12 UTC
Re: file_column: patched for imagemagick and validation
On Sep 9, 2005, at 1:30 AM, Kyle Maxwell wrote:> Hi all, > > I patched file_column to add imagemagick transformations of uploaded > content.Kyle, This patch is wonderful, I''m glad to have discovered it! I haven''t had a chance to play around with it yet, but already I have a suggestion! What about allowing :magick to accept an array of option strings, allowing one to (for example) generate several sizes of images on upload, and have them automatically removed along with the record? Thanks, Raymond
Kyle Maxwell
2005-Sep-22 07:50 UTC
Re: file_column: patched for imagemagick and validation
I was on my way to allowing multiple versions of the same image, for thumbnails, etc, but it hasn''t been a real priority. Maybe in the upcoming weeks. I''m planning to always do the imagemagick transformations on the way in, rather generating just-in-time. I''d much rather use hard drive space than increase latency and use cpu. Kyle Maxwell On 9/21/05, Raymond Brigleb <ray-THGPwszTed5CpjqP0VxSwUEOCMrvLtNR@public.gmane.org> wrote:> On Sep 9, 2005, at 1:30 AM, Kyle Maxwell wrote: > > > Hi all, > > > > I patched file_column to add imagemagick transformations of uploaded > > content. > > Kyle, > > This patch is wonderful, I''m glad to have discovered it! I haven''t > had a chance to play around with it yet, but already I have a > suggestion! > > What about allowing :magick to accept an array of option strings, > allowing one to (for example) generate several sizes of images on > upload, and have them automatically removed along with the record? > > Thanks, > Raymond >
I agree with you in that aspect, you should definitely create the different sizes and store them on the HD on the way in, rather than doing them just-in-time. But it would be nice to have some cool filter effects done on the fly.. I know ImageMagick can perform some pretty cool effects on images. Maybe this is all out of the scope of this patch or even file_column and should be put into another library for doing simple RMagick transformations? Either way, thanks for the great code guys.. I''m using this on my site right now and it works great. My needs are pretty simple right now, but im hoping as my needs grow, so will the functionality of this package :-) On 9/22/05, Kyle Maxwell <kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org> wrote:> I was on my way to allowing multiple versions of the same image, for > thumbnails, etc, but it hasn''t been a real priority. Maybe in the > upcoming weeks. > > I''m planning to always do the imagemagick transformations on the way > in, rather generating just-in-time. I''d much rather use hard drive > space than increase latency and use cpu. > > Kyle Maxwell > > On 9/21/05, Raymond Brigleb <ray-THGPwszTed5CpjqP0VxSwUEOCMrvLtNR@public.gmane.org> wrote: > > On Sep 9, 2005, at 1:30 AM, Kyle Maxwell wrote: > > > > > Hi all, > > > > > > I patched file_column to add imagemagick transformations of uploaded > > > content. > > > > Kyle, > > > > This patch is wonderful, I''m glad to have discovered it! I haven''t > > had a chance to play around with it yet, but already I have a > > suggestion! > > > > What about allowing :magick to accept an array of option strings, > > allowing one to (for example) generate several sizes of images on > > upload, and have them automatically removed along with the record? > > > > Thanks, > > Raymond > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- - Ramin http://www.getintothis.com/blog