

Ask HN: image scaling on the fly - Erlend

Hi,<p>I've built some mobile sites &#38; apps the last few years and rescaling images keeps popping up.<p>Ideally I would want something like this:<p>http://scal.er/w40-a1:1/http://path/to/image<p>this would generate a square thumb, 40x40.<p>I would be willing to pay for such a service.
======
hernan7
Why not use ImageMagick?

I have used it to create thumbnails for a demo website and they looked OK.
Does it have any performance/ aliasing/ whatever issues I'm not aware of?

~~~
johngunderman
ImageMagick is gold for this sort of thing. I'm actually working with it as I
type :)

------
Mentat_Enki
Was there a question being asked here? If you are looking for a programmer-
for-hire, there are freelance sites for that sort of thing. This isn't even an
hard/interesting problem, and anyone who could "build a mobile site/app"
should be able to code up this trivial service in minutes.

~~~
Erlend
Sorry, I wasn't clear enough earlier.

I have used imagemagick/GD previusly, but there are some hassle involved in
setting up this for each project/client (cron job for cleaning up thumbs,
space considerations, not all ISP I use for clients have GD installed etc)

I agree that writing an ad-hoc image scaler is simle.

However, writing a quality general one that handles different formats, image
quality, aspect ratio, smart cropping etc..is not trivial.

~~~
Mentat_Enki
Righty-o. Didn't mean to sound annoyed, but there has been a bit more
Craigslist-y trolling-for-programmers-for-hire than usual lately it seems, and
that kinda stuff needs some trouncing IMHO. :)

Also, you are going to be limited to the tools for processing images that are
out there for the most part, which sadly means ImageMagick and/or GD. But not
SO sadly, as both of those (while annoying to deploy, granted...) have decent
bindings to everything, support a pretty good selection of images types, and
have params for controlling the aspects you mentioned (except maybe smart
cropping).

Everything else is arithmetic and designing a clean, RESTful URL scheme for
invoking it. I guess I meant trivial in the sense that all these things are
solved problems or only require a bit of time/cleverness.

I built one of these a few years ago using PHP/GD, and it performed admirably
(and did everything except smart cropping in your aforementioned list...)

So, feel free to hit me up if you get stuck on any specifics. Been there done
that, and can commisserate if nothing else. ;)

~~~
Erlend
Thanks for that, I'll let you know if I get stuck.

------
andrewingram
At work I developed a wsgi script that use Python Imaging Library to resize
images on demand. You can see it in action here:

[http://dyn4.media.forbiddenplanet.com/products/2148557.jpg.s...](http://dyn4.media.forbiddenplanet.com/products/2148557.jpg.size-300_square-
true.jpg)
[http://dyn4.media.forbiddenplanet.com/products/2148557.jpg.s...](http://dyn4.media.forbiddenplanet.com/products/2148557.jpg.size-300_square-
true.gif)

Basically, if you chop off the dyn4 sub-subdomain and everything after .jpg
you can see the original unmodified image. You can also change the extension
at the end to change the format of the image (jpg,png or gif). We cache the
files to /tmp which we periodically clear out. Whilst it might be more
efficient of going down the route of pre-generating all the images we'll need,
it's very convenient being able to do it on the fly and to be honest for a
site of our size (225,000 visits/month) it's barely a spec on the CPU load of
our media server.

There's also an apache module that uses ImageMagick to do something similar:

<http://github.com/beetlebugorg/mod_dims>

I have to be honest though, I prefer the API for my version and it gives the
files a meaningful name in the /tmp folder as well as the user's internet
history.

Unfortunately my version isn't open source (yet?) and the code is a bit of a
mess, but it's something we have considered opening up.

------
raystar
There is <http://imagejuicer.com/>, that seems to do what you want.

~~~
thinkzig
Has anyone here used Image Juicer?

It looks interesting but I found the documentation page to be pretty lacking.
The simple example they show just allows you to pass a height and width
parameter, but the home page says you can do cropping, watermarking, etc.

~~~
raystar
From their site:

You can pass other info in the outputs hashes, like labels, your own ids, or
whatever. That extra info will be passed back to you in the response JSON.

So I assume it is a case of emailing them and asking for an exhaustive list of
what can be passed to their api, the documentation definitely needs work.

------
anathem
I'm currently wrapping up work on an image processing module with a client. If
you want I could build a dedicated service for you.

If you are running your own site, and using nginx, there's an image processing
module for it that is a match for your requirement:
<http://wiki.nginx.org/NginxHttpImageFilterModule>

~~~
Erlend
Thanks for that, but Im looking for a "pay as you go" service.

------
macca321
I wrote a HTML=>PNG service last week
(<http://htmltoimage.tenprinthello.com>), so it's just a hop to an image
resizer.

If you want one developed, please contact me, my email is on my blog @
<http://www.adverseconditionals.com>

------
cromulent
<http://wiki.nginx.org/NginxHttpImageFilterModule>

------
audionerd
I've been impressed with Dragonfly, "a Rack-based ruby gem for [image]
processing/encoding on the fly"

    
    
      http://blog.new-bamboo.co.uk/2010/1/2/dragonfly

------
wan23
I've thought the same thing. Seems like something that needs to be done over
and over. It seems like a good potential business idea as long as it's cheap
enough.

------
anarchitect
I think urlimg might be what you are looking for... <http://urlimg.com/>

~~~
Erlend
Thanks, will take a closer look, but pricing seems off (1 cent/mb/month over
50mb)

------
theIntuitionist
I'd be happy to build you such a service. Would be quite simple. email me-
theIntuitionist@idont.no

~~~
tjarratt
Off topic, but why do you have all of your files browsable at
<http://idont.no> ?

You should set up a landing page at least, so visitors don't just see /www
directory.

------
Concours
you may want to try this: <http://gaia-git.sourceforge.net/> it targets mobile
devices, so could be what you are looking for.

------
l4u
try <http://cdn-cloud.appspot.com/> despite the name "cdn", it provides
functions for scaling

~~~
Erlend
Thanks, looks useful, but didnt find any Terms of service or pricing info..

