Hi all,
I added *multiple* imagemagick handlers to file_column in the easiest
and most straightforward manner I could.  I haven''t modified the rdoc
yet though, so sample usage is included at the bottom of the email. 
See http://www.imagemagick.org/script/command-line-options.php for the
imagemagick options usage.
The main imagemagick transformation is applied on the initial upload. 
So it is available for unsaved models through the temporary name.  The
:alternate transformations are applied as part of the after_save
callback.  This suited my needs, and I hope it suits yours as well. 
I''m posting my working files.  As always, alpha-quality code, use at
your own risk.
Kyle Maxwell
#Examples:
#----------------------------
file_column :field, :magick => " -resize
\"1000x1000>\""
file_column :format => [".pdf", ".doc"] #multiple formats
allowed if
you want to simply validate the file type.
file_column :field, :magick => " -resize
\"1000x1000>\"", :format =>
".jpg", :alternate => {"thumb.jpg" => "-resize
\"100x100>\"",
"inverted.jpg" => "-rotate 180"}
Model.find(:first).field_alternate_images #=> ["thumb.jpg",
"inverted.jpg"]
<%=url_for_file_column "record", "field" %> #=>
default image
<%=url_for_file_column "record", "field",
"thumb.jpg" %>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
So, I would need to add a new column to my table and call it alternate? A little confused about the whole alternate thing. Can you please explain that a little more? Do you have any plans to extend this to allow for image gallery type functionality. Allowing user to add many images? Thanks On 9/24/05, Kyle Maxwell <kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org> wrote:> Hi all, > > I added *multiple* imagemagick handlers to file_column in the easiest > and most straightforward manner I could. I haven''t modified the rdoc > yet though, so sample usage is included at the bottom of the email. > See http://www.imagemagick.org/script/command-line-options.php for the > imagemagick options usage. > > The main imagemagick transformation is applied on the initial upload. > So it is available for unsaved models through the temporary name. The > :alternate transformations are applied as part of the after_save > callback. This suited my needs, and I hope it suits yours as well. > I''m posting my working files. As always, alpha-quality code, use at > your own risk. > > Kyle Maxwell > > #Examples: > #---------------------------- > file_column :field, :magick => " -resize \"1000x1000>\"" > > file_column :format => [".pdf", ".doc"] #multiple formats allowed if > you want to simply validate the file type. > > file_column :field, :magick => " -resize \"1000x1000>\"", :format => > ".jpg", :alternate => {"thumb.jpg" => "-resize \"100x100>\"", > "inverted.jpg" => "-rotate 180"} > > Model.find(:first).field_alternate_images #=> ["thumb.jpg", "inverted.jpg"] > > <%=url_for_file_column "record", "field" %> #=> default image > > <%=url_for_file_column "record", "field", "thumb.jpg" %> > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-- - Ramin http://www.getintothis.com/blog
Hope the following makes things clearer:
No, you don''t need to create an alternate column in your database. The
"alternate thing" is a way to store multiple representations of the
same image.   You might upload an image, say a desktop wallpaper like
this:
Create a table "wallpapers" with id(int autoincrement), name
(varchar), image(varchar)
#Model
def Wallpaper
  file_column :image, :magick => "-normalize", :alternate =>
{"800.jpg" => "-resize 800x600!", "1024.jpg"
=> "-resize 1024x768!",
"thumb.jpg" => "-resize 100x100"}
end
def controller_method
  w = Wallpaper.new
  w.name = "My wallpaper"
  w.image = params[:my_uploaded_file]
  w.save
  @wallpapers = Wallpaper.find :all
end
#View code
<% for @wallpaper in @wallpapers%>
  <p><%=image_tag url_for_file_column("wallpaper",
"image",
"thumb.jpg"), :alt => wallpaper.name %><br />
  <%=link_to "Original image",
url_for_file_column("wallpaper", "image") %> |
  <%=link_to "800x600", url_for_file_column("wallpaper",
"image",
"800.jpg") %> |
  <%=link_to "1024x768", url_for_file_column("wallpaper",
"image",
"1024.jpg") %>
  </p>
<% end %>
On 9/25/05, Ramin <i8ramin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> So, I would need to add a new column to my table and call it
> alternate? A little confused about the whole alternate thing. Can you
> please explain that a little more?
>
> Do you have any plans to extend this to allow for image gallery type
> functionality. Allowing user to add many images?
>
> Thanks
>
> On 9/24/05, Kyle Maxwell
<kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org> wrote:
> > Hi all,
> >
> > I added *multiple* imagemagick handlers to file_column in the easiest
> > and most straightforward manner I could.  I haven''t modified
the rdoc
> > yet though, so sample usage is included at the bottom of the email.
> > See http://www.imagemagick.org/script/command-line-options.php for the
> > imagemagick options usage.
> >
> > The main imagemagick transformation is applied on the initial upload.
> > So it is available for unsaved models through the temporary name.  The
> > :alternate transformations are applied as part of the after_save
> > callback.  This suited my needs, and I hope it suits yours as well.
> > I''m posting my working files.  As always, alpha-quality code,
use at
> > your own risk.
> >
> > Kyle Maxwell
> >
> > #Examples:
> > #----------------------------
> > file_column :field, :magick => " -resize
\"1000x1000>\""
> >
> > file_column :format => [".pdf", ".doc"]
#multiple formats allowed if
> > you want to simply validate the file type.
> >
> > file_column :field, :magick => " -resize
\"1000x1000>\"", :format =>
> > ".jpg", :alternate => {"thumb.jpg" =>
"-resize \"100x100>\"",
> > "inverted.jpg" => "-rotate 180"}
> >
> > Model.find(:first).field_alternate_images #=>
["thumb.jpg", "inverted.jpg"]
> >
> > <%=url_for_file_column "record", "field" %>
#=> default image
> >
> > <%=url_for_file_column "record", "field",
"thumb.jpg" %>
> >
> >
> > _______________________________________________
> > Rails mailing list
> > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails
> >
> >
> >
> >
>
>
> --
> - Ramin
> http://www.getintothis.com/blog
>