00146: Automatic thumbnails and image sizing

Summary: Automatic thumbnails and image sizing
Created: 2004-11-08 15:13
Status: Closed - added to cookbook
Category: Feature
From: PRZ
Assigned:
Priority: 532
Version: any
OS:

Description: Before uploading images, one of the most tedious jobs is to resize images, create thumbnails, and write Copyright and Caption in IPTC fields.

It exists gallery extension in cookbook to help create images galleries, but when adding individually images to a general document, no tool exist.

To replace the notation [[Attach:SmallImage.ext -> Attach:PlainImage.ext]] and automatically resize images, we can create a call like :

Img:image.ext

Which may be the equivalent of the notation :

[[Attach:image.s.ext -> Attach:image.p.ext]]

When clicking the first time on Img:image.ext we shall open a windows which will ask :

1/ Upload image.ext, after the upload a thumbnail shall be displayed in order to check if this is the good image.

2/ Then we shall answer :

  • what are the desired size for plain image and small image
  • what is the copyright, caption and special instructions

After acceptation, the files shall be created :

  • image.s.ext is the small image
  • image.p.ext is the plain image which shall be displayed when clicking on the thumbnail.
  • image.ext is no longer needed but shall stay as archive in case of future resizing. Administrator may choose to delete or archive this file. Maybe automatically deleted if the plain image is of same size as the source image.

IPTC informations about Copyright, Caption and Special instructions shall be written on these three files.

Then, we shall go back the calling page.

The Upload image Windows / Page may look as below :

The dimension defined in the window is the larger one, being it height or width, and the H/W ratio should be respected.

In addition, in order to avoid image quality loss, if the actual image size is within the lower or higher range of the required size, image size should remained unmodified. e.g. if the image width is 770, asking an image size of 768 or 832 should left the image unmodified. Also, images can only be downsized, not upsized.

  • Copyright maybe prefilled with the Author name
  • Caption maybe prefilled with a content defined in a variable (to give a general subject or indicate it is on a given Wiki, per example)
  • Special instructions may be prefilled with a content defined in a variable (to defined artistic licence, per example)
  • Variables shall define the default size for thumbnails and plain images.

Some may object than the thumbnails size as defined in the page are relatively large. In fact, this is more 'small images' than thumbnails.
Though, to have everyone happy, this should be parametrable.

IPTC fields containing Copyright, Caption, etc. are only available for jpeg images, so shall not be requested when uploading a gif image. What about png ?

I know this feature represent some work, but i have no clue about PHP or HTML forms (and i am not a programmer, also..), so unable to do that myself without a big amount of work. But i think this can be a very useful tool. Anyway, i'll be happy to participate as far as i can.


The biggest obstacle to implementing something like this is that it's very hard in PHP to create the thumbnail images -- a lot of PHP installations don't have support for resizing images (or if they do, the resized image is very poor quality). So, until there's good, reliable PHP functionality for resizing images (that will work on many different platforms), this feature request will probably have to be a suspended one. Although it can certainly be made into a Cookbook item for specific PHP environments. --Pm


I have checked 3 webhoster, 2 paying and one free, all have GD library installed in version 2 or above (no exact revision given). GD library with revision above 2.03 allow resampling method for image resizing, and so, supposedly a good image quality.
I know that 3 hosts is not quite a representative statistic sample, but at least, this is encouraging... PRZ


Indeed, that's very encouraging! My suggestion for now is that this be developed as a Cookbook script, with an eye towards including it in a future distribution. --Pm


Done - see Cookbook/ImagesAutoResizing - PRZ


See also Cookbook.ThumbList. --Petko