0

For those unaware of TimThumb, it will take any image, of any size or dimension and create a thumbnail on the fly to any desired size. The beauty of it is that it really works on any dimension you feed it through a combination of either resizing the image, cropping or zoom cropping the image.

Ive been searching for jscript equvalents but they either require the user to actually mask out the thumbs manually (looking for a script that automatically does it to images) or the scripts can't handle images in a different aspect ratio.

Thanks for any leads on this!

Mark
  • 3,653
  • 10
  • 30
  • 62

2 Answers2

0

It is impossible to do this only with client-side javascript. PHP has GD, ImageMagick libraries which create the new image (actual thumbnail) and javascript alone can't do this, as it is client side script, it can't create files.

So the answer is: There is no any.

As @papirtiger pointed out you can still do it with server-side javascript (such as node.js).

Please see this link

Community
  • 1
  • 1
Arman P.
  • 4,314
  • 2
  • 29
  • 47
  • Darn, although I dont need the script to physically create a file to save, just to display on a mobile site, so it just has to trickily resize the image and then frame it in divs to look like a thumbnail of a predetermined size I guess – Mark Mar 21 '12 at 23:51
  • 1
    javascript has been running on servers for a long time. – max Mar 21 '12 at 23:58
  • @Mark Hey!!! Why -1? The javascript can load your image and resize it to your desired sizes. But it will load the actueal (big) picture and resize it (simply imagine give it css width and height with DOM). It's unpractical. – Arman P. Mar 21 '12 at 23:58
  • @papirtiger Sure, I don't know whether there is a way to do it with server-side javascript. (edited answer to reflect this) – Arman P. Mar 22 '12 at 00:00
  • 1
    @ArmanP. http://stackoverflow.com/questions/4541332/whats-the-best-graphics-library-for-node-js-for-image-cropping – max Mar 22 '12 at 00:08
  • @ArmanP No -1 from me my man. I do appreciate the time to help me out. – Mark Mar 22 '12 at 00:25
0

It depends.

You can use CSS or Javascript for simple image scaling.
There are tons of available plugins to this.

I doubt that there is one that does the guesstimation exactly the same as timthumb.

If you are going resize a large amount images on the page it will really hurt performance. Another alternative is to several fixed size "layouts" (960, 320) etc and have the server generate thumbs for each.

You can than use javascript to load the appriate size.

If you really need to rescale the file:

Use external webservice to resize the image. Most of them take a url and return a resized image:

example.com/resize?image="http://example.com/image1.jpg"&height="...

If you have TimThumb running on your server you can set up a simple API to allow you to call your own service.

othrwise see Image resizing web service for a few alternatives.

Community
  • 1
  • 1
max
  • 96,212
  • 14
  • 104
  • 165