John Kopanas wrote:> On my website people will be able to upload images of themselves. I > was wondering how people are presently handling uploading, resizing > and optimizing images in Rails? Do you use a specific piece of > software to do it?RMagick is quite often used. Google for RMagick thumbnails -- check out the piece on change_geometry. It''ll helps you resize to a maximum dimentions which preserving aspect ratio.> Also, do you guys store the images in the DB or just as files? What > do you suggest? What are the pros and cons?Storing images in the db is much easier, but many don''t like doing so. Some people use the db and then use page caching to cache the image files into public.
On my website people will be able to upload images of themselves. I was wondering how people are presently handling uploading, resizing and optimizing images in Rails? Do you use a specific piece of software to do it? What would you guys recommend? Any code from RailsDay? :-) Also, do you guys store the images in the DB or just as files? What do you suggest? What are the pros and cons? I greatly appreciate your feedback. John
It''s generally faster to store images as files (doubly so because if you store them in /public, you don''t even have to use rails to send them to the user). The problem with that approach is that you have to write more code (ActiveRecord doesn''t support that sort of thing out-of-the-box), and your data is spread out between several locations. So it''s more of a pain in the neck, but it''s usually the "right way" to do things. Tyler On 6/6/05, John Kopanas <john.kopanas-O1KSuMybMhqBUy7/sJONFg@public.gmane.org> wrote:> On my website people will be able to upload images of themselves. I > was wondering how people are presently handling uploading, resizing > and optimizing images in Rails? Do you use a specific piece of > software to do it? What would you guys recommend? Any code from > RailsDay? :-) > > Also, do you guys store the images in the DB or just as files? What > do you suggest? What are the pros and cons? > > I greatly appreciate your feedback. > > John > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Mon, Jun 06, 2005 at 12:28:42PM -0400, John Kopanas wrote:> On my website people will be able to upload images of themselves. I > was wondering how people are presently handling uploading, resizing > and optimizing images in Rails? Do you use a specific piece of > software to do it? What would you guys recommend? Any code from > RailsDay? :-) > > Also, do you guys store the images in the DB or just as files? What > do you suggest? What are the pros and cons? > > I greatly appreciate your feedback.This is essentially what I did for railsday. File upload of either individual or tarball of images (unpacked via mini-tar), these get resized on upload using RMagick and stored in a directory structure with meta data going to the database. Feel free to check out the code: http://www.railsday.com/svn/railsday10/ Take a look at the AdminController, ImageController, and the PhotoModel. As always opinions, thoughts and recommendations are welcome. It looks like there were several gallery style applications on Railsday. I haven''t had a chance to look at them yet to see how they did all the image manipulation, but scroll through http://www.railsday.com/svn/ and see which ones look interesting. enjoy, -jeremy -- ======================================================================= Jeremy Hinegardner jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org
I have never done any testing as to how much of a difference performance is on storing small images in a database vs. a filesystem. Any ideas? --- Jeremy Hinegardner <jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org> wrote:> On Mon, Jun 06, 2005 at 12:28:42PM -0400, John > Kopanas wrote: > > On my website people will be able to upload images > of themselves. I > > was wondering how people are presently handling > uploading, resizing > > and optimizing images in Rails? Do you use a > specific piece of > > software to do it? What would you guys recommend? > Any code from > > RailsDay? :-) > > > > Also, do you guys store the images in the DB or > just as files? What > > do you suggest? What are the pros and cons? > > > > I greatly appreciate your feedback. > > This is essentially what I did for railsday. File > upload of either > individual or tarball of images (unpacked via > mini-tar), these get > resized on upload using RMagick and stored in a > directory structure with > meta data going to the database. Feel free to check > out the code: > > http://www.railsday.com/svn/railsday10/ > > Take a look at the AdminController, ImageController, > and the > PhotoModel. As always opinions, thoughts and > recommendations are > welcome. > > It looks like there were several gallery style > applications on Railsday. > I haven''t had a chance to look at them yet to see > how they did all the > image manipulation, but scroll through > http://www.railsday.com/svn/ and > see which ones look interesting. > > enjoy, > > -jeremy > > > -- >=======================================================================> Jeremy Hinegardner> jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
What about any programs that allow color optimization (like auto contrast and auto levels in photoshop)? Thanks :-) On 6-Jun-05, at 1:30 PM, Michael Gorsuch wrote:> I have never done any testing as to how much of a > difference performance is on storing small images in a > database vs. a filesystem. > > Any ideas? > > > --- Jeremy Hinegardner <jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org> wrote: > >> On Mon, Jun 06, 2005 at 12:28:42PM -0400, John >> Kopanas wrote: >> >>> On my website people will be able to upload images >>> >> of themselves. I >> >>> was wondering how people are presently handling >>> >> uploading, resizing >> >>> and optimizing images in Rails? Do you use a >>> >> specific piece of >> >>> software to do it? What would you guys recommend? >>> >> Any code from >> >>> RailsDay? :-) >>> >>> Also, do you guys store the images in the DB or >>> >> just as files? What >> >>> do you suggest? What are the pros and cons? >>> >>> I greatly appreciate your feedback. >>> >> >> This is essentially what I did for railsday. File >> upload of either >> individual or tarball of images (unpacked via >> mini-tar), these get >> resized on upload using RMagick and stored in a >> directory structure with >> meta data going to the database. Feel free to check >> out the code: >> >> http://www.railsday.com/svn/railsday10/ >> >> Take a look at the AdminController, ImageController, >> and the >> PhotoModel. As always opinions, thoughts and >> recommendations are >> welcome. >> >> It looks like there were several gallery style >> applications on Railsday. >> I haven''t had a chance to look at them yet to see >> how they did all the >> image manipulation, but scroll through >> http://www.railsday.com/svn/ and >> see which ones look interesting. >> >> enjoy, >> >> -jeremy >> >> >> -- >> >> > ====================================================================== > => >> Jeremy Hinegardner >> jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
John Kopanas <john.kopanas-O1KSuMybMhqBUy7/sJONFg@public.gmane.org> writes:> What about any programs that allow color optimization (like auto > contrast and auto levels in photoshop)?I think your best bet is to look into scripting gimp for some of that. That level of image manipulation could get tricky. -- doug-jGAhs73c5XxeoWH0uzbU5w@public.gmane.org
You can run Gimp as a server: http://people.westminstercollege.edu/alumni/d-b1649/linux/gimp_server.html Dave On 6/6/05, John Kopanas <john.kopanas-O1KSuMybMhqBUy7/sJONFg@public.gmane.org> wrote:> What about any programs that allow color optimization (like auto > contrast and auto levels in photoshop)? > > Thanks :-) > > On 6-Jun-05, at 1:30 PM, Michael Gorsuch wrote: > > > I have never done any testing as to how much of a > > difference performance is on storing small images in a > > database vs. a filesystem. > > > > Any ideas? > > > > > > --- Jeremy Hinegardner <jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org> wrote: > > > >> On Mon, Jun 06, 2005 at 12:28:42PM -0400, John > >> Kopanas wrote: > >> > >>> On my website people will be able to upload images > >>> > >> of themselves. I > >> > >>> was wondering how people are presently handling > >>> > >> uploading, resizing > >> > >>> and optimizing images in Rails? Do you use a > >>> > >> specific piece of > >> > >>> software to do it? What would you guys recommend? > >>> > >> Any code from > >> > >>> RailsDay? :-) > >>> > >>> Also, do you guys store the images in the DB or > >>> > >> just as files? What > >> > >>> do you suggest? What are the pros and cons? > >>> > >>> I greatly appreciate your feedback. > >>> > >> > >> This is essentially what I did for railsday. File > >> upload of either > >> individual or tarball of images (unpacked via > >> mini-tar), these get > >> resized on upload using RMagick and stored in a > >> directory structure with > >> meta data going to the database. Feel free to check > >> out the code: > >> > >> http://www.railsday.com/svn/railsday10/ > >> > >> Take a look at the AdminController, ImageController, > >> and the > >> PhotoModel. As always opinions, thoughts and > >> recommendations are > >> welcome. > >> > >> It looks like there were several gallery style > >> applications on Railsday. > >> I haven''t had a chance to look at them yet to see > >> how they did all the > >> image manipulation, but scroll through > >> http://www.railsday.com/svn/ and > >> see which ones look interesting. > >> > >> enjoy, > >> > >> -jeremy > >> > >> > >> -- > >> > >> > > =====================================================================> > => > > >> Jeremy Hinegardner > >> jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Site: http://dave.antidisinformation.com/
On 6/7/05, Michael Gorsuch <mgorsuch-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> wrote:> I have never done any testing as to how much of a > difference performance is on storing small images in a > database vs. a filesystem.Define small? With a lot of DBs, blobs larger than 4k get written to a seperate file anyway.> Any ideas?I wouldn''t let performance worries cloud your judgement here. The reality is that with a service deployed over the internet, upload and download of images will take much longer than storage and retrieval from disk. Their internet connection is bound to be slower than your disks, if not, buy new disks. If you search the mailling list archives, you''ll find lots of complaints about performance problems with blobs and Active Record. Mostly around the fact that we don''t, yet, use the database''s prepared statement support. I personally use the filesystem.> > --- Jeremy Hinegardner <jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org> wrote: > > On Mon, Jun 06, 2005 at 12:28:42PM -0400, John > > Kopanas wrote: > > > On my website people will be able to upload images > > of themselves. I > > > was wondering how people are presently handling > > uploading, resizing > > > and optimizing images in Rails? Do you use a > > specific piece of > > > software to do it? What would you guys recommend? > > Any code from > > > RailsDay? :-) > > > > > > Also, do you guys store the images in the DB or > > just as files? What > > > do you suggest? What are the pros and cons? > > > > > > I greatly appreciate your feedback. > > > > This is essentially what I did for railsday. File > > upload of either > > individual or tarball of images (unpacked via > > mini-tar), these get > > resized on upload using RMagick and stored in a > > directory structure with > > meta data going to the database. Feel free to check > > out the code: > > > > http://www.railsday.com/svn/railsday10/ > > > > Take a look at the AdminController, ImageController, > > and the > > PhotoModel. As always opinions, thoughts and > > recommendations are > > welcome. > > > > It looks like there were several gallery style > > applications on Railsday. > > I haven''t had a chance to look at them yet to see > > how they did all the > > image manipulation, but scroll through > > http://www.railsday.com/svn/ and > > see which ones look interesting. > > > > enjoy, > > > > -jeremy > > > > > > -- > > > =======================================================================> > Jeremy Hinegardner > > jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
Thanks for the reply. I will ultimately be performing my own tests, but wanted to see if there was a consensus. Thanks, Michael On Jun 6, 2005, at 3:02 PM, Michael Koziarski wrote:> On 6/7/05, Michael Gorsuch <mgorsuch-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> wrote: >> I have never done any testing as to how much of a >> difference performance is on storing small images in a >> database vs. a filesystem. > > Define small? With a lot of DBs, blobs larger than 4k get written to > a seperate file anyway. > >> Any ideas? > > I wouldn''t let performance worries cloud your judgement here. The > reality is that with a service deployed over the internet, upload and > download of images will take much longer than storage and retrieval > from disk. Their internet connection is bound to be slower than your > disks, if not, buy new disks. > > If you search the mailling list archives, you''ll find lots of > complaints about performance problems with blobs and Active Record. > Mostly around the fact that we don''t, yet, use the database''s prepared > statement support. > > I personally use the filesystem. > >> >> --- Jeremy Hinegardner <jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org> wrote: >>> On Mon, Jun 06, 2005 at 12:28:42PM -0400, John >>> Kopanas wrote: >>>> On my website people will be able to upload images >>> of themselves. I >>>> was wondering how people are presently handling >>> uploading, resizing >>>> and optimizing images in Rails? Do you use a >>> specific piece of >>>> software to do it? What would you guys recommend? >>> Any code from >>>> RailsDay? :-) >>>> >>>> Also, do you guys store the images in the DB or >>> just as files? What >>>> do you suggest? What are the pros and cons? >>>> >>>> I greatly appreciate your feedback. >>> >>> This is essentially what I did for railsday. File >>> upload of either >>> individual or tarball of images (unpacked via >>> mini-tar), these get >>> resized on upload using RMagick and stored in a >>> directory structure with >>> meta data going to the database. Feel free to check >>> out the code: >>> >>> http://www.railsday.com/svn/railsday10/ >>> >>> Take a look at the AdminController, ImageController, >>> and the >>> PhotoModel. As always opinions, thoughts and >>> recommendations are >>> welcome. >>> >>> It looks like there were several gallery style >>> applications on Railsday. >>> I haven''t had a chance to look at them yet to see >>> how they did all the >>> image manipulation, but scroll through >>> http://www.railsday.com/svn/ and >>> see which ones look interesting. >>> >>> enjoy, >>> >>> -jeremy >>> >>> >>> -- >>> >> ====================================================================== >> =>>> Jeremy Hinegardner >>> jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > -- > Cheers > > Koz >
On Mon, Jun 06, 2005 at 02:51:00PM -0400, John Kopanas wrote:> What about any programs that allow color optimization (like auto > contrast and auto levels in photoshop)? >I would go for RMagick. I''ve found it quite easy to get going using it an many of these types of operations are already included: http://studio.imagemagick.org/RMagick/doc/image2.html#level http://studio.imagemagick.org/RMagick/doc/image2.html#level_channel Tim has done an amazing job on RMagick. I''m pretty much using it for any sort of scripted image manipulation these days.> On 6-Jun-05, at 1:30 PM, Michael Gorsuch wrote: > > >I have never done any testing as to how much of a > >difference performance is on storing small images in a > >database vs. a filesystem. > > > >Any ideas? > >My bias is towards storing all images on the filesystem. Since the vast majority of the time, when delivering an image to a webbrowser, it just needs to send the file contents, that is best performed by a web server, not an application. My approach is to upload the images into the application, the application then stores the files in predetermined directories. Then when sending back the HTML the <img src=""> tags points to the URL of the image file and the image GET request never even hits the webapplication. You can''t get much better performance of sending a file on a files sytem to a webrowser than just the basic HTTP GET request and using lighttpd or the like to respond to it. Use the right tool for the job :-) If your image load is pretty high, then even moving the images to another machine to just send out images is a good solution too. Of course, the common scenario may not be your scenario so just my $.02, YMMV etc. enjoy, -jeremy -- ======================================================================= Jeremy Hinegardner jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org
Just for completeness. I store my images in blobs in the database but use caches_page so that they are dumped to the file system upon first request. This has slight advantages since a sqldump actually contains the entire application with all its data and multiple web server still each have the same images. The speed is the same since the web server handles serving the image directly. Its definitely a valid approach, it might just be more trouble then its worth.> My bias is towards storing all images on the filesystem. Since the vast > majority of the time, when delivering an image to a webbrowser, it just > needs to send the file contents, that is best performed by a web server, > not an application. > > My approach is to upload the images into the application, the > application then stores the files in predetermined directories. Then > when sending back the HTML the <img src=""> tags points to the URL of > the image file and the image GET request never even hits the > webapplication. You can''t get much better performance of sending a file > on a files sytem to a webrowser than just the basic HTTP GET request > and using lighttpd or the like to respond to it. > > Use the right tool for the job :-) If your image load is pretty high, > then even moving the images to another machine to just send out images > is a good solution too. > > Of course, the common scenario may not be your scenario so just my $.02, > YMMV etc.-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://typo.leetsoft.com - Open source weblog engine http://blog.leetsoft.com - Technical weblog
On Tue, Jun 07, 2005 at 05:34:32PM -0700, Robert Mannl wrote:> > > > >This is essentially what I did for railsday. File upload of either > >individual or tarball of images (unpacked via mini-tar), these get > >resized on upload using RMagick and stored in a directory structure with > >meta data going to the database. Feel free to check out the code: > > > > > > > Did you have to use GC.start in your application? Just wondering > > See http://wiki.rubyonrails.com/rails/show/Gotcha "RMagick results in > your apps going mental, memory wise" on the bottom of the pageYes, all the RMagick calls are confined below a single method (after_create) in photo.rb and a call GC.start is made at the end of the method before returning. Or course this hasn''t seen much usage so I don''t know if it was done correctly or not. enjoy, -jeremy -- ======================================================================= Jeremy Hinegardner jeremy-eg9WJcVQRd1EMKyauTCisw@public.gmane.org
if i''m not mistaken rails calls GC.start after handling a request now all by itself. It could be that this is part of the upcoming performance improvements though.> > Did you have to use GC.start in your application? Just wondering > > > > See http://wiki.rubyonrails.com/rails/show/Gotcha "RMagick results in > > your apps going mental, memory wise" on the bottom of the page >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://typo.leetsoft.com - Open source weblog engine http://blog.leetsoft.com - Technical weblog
> >This is essentially what I did for railsday. File upload of either >individual or tarball of images (unpacked via mini-tar), these get >resized on upload using RMagick and stored in a directory structure with >meta data going to the database. Feel free to check out the code: > > >Did you have to use GC.start in your application? Just wondering See http://wiki.rubyonrails.com/rails/show/Gotcha "RMagick results in your apps going mental, memory wise" on the bottom of the page Cheers, Rob