When it comes to
web development, sooner or later the question arises of how and how to prepare a thumbnail on the side of the web server. The question of manual preparation disappears automatically, it is much more pleasant to upload a picture and not to think about anything else. Here's how to not think, and will be discussed.
At first, like many others, my mind was opened by 2 magnificent libraries
ImageMagick and
GD .
Rich functionality and all that, I will not describe the charms ...
because it's not about them. And at first I thought that there was no limit to perfection, until I came across hosting on which there is no
PHP and there is no
Perl (I write on
Parser , if that). And there really was a problem.
The solution was found by
itself , picking at the favorite image viewer
XnView, I found a funny utility NConvert that allows you to do various manipulations with graphic files (long list of functions + support for 400 graphic formats + implementation for all platforms).
One of the most remarkable advantages that I have noted for myself is changing jpeg files (rotation, flip) without recompression. Is this not a fairy tale. I even wrote an article on the Parser
forum (we read who is interested).
However, just a week ago, my mind again forced me to rush in search of the perfect solution, and it was found.
Meet -
jpegtranThe utility that exists on all
Unix-like systems is included in the jpeg library. There is also an implementation under
Windows .
What does she allow to do? It allows you to perform various manipulations (clipping meta data, turning, reflecting, cropping, resizing
, etc. ) with jpeg without recompression.
Full list of functions:
usage: jpegtran [switches] [inputfile]
Switches (names may be abbreviated):
Copy no extra markers from source file
-copy comments Copy only comment markers (default)
-copy all Copy all extra markers
-optimize Huffman table (smaller file, but slow compression)
-progressive create progressive jpeg file
Switches for modifying the image:
-grayscale Reduce to grayscale (omit color data)
-flip [horizontal | vertical] Mirror image ( left-right or top-bottom )
-rotate [90 | 180 | 270] Rotate image (degrees clockwise)
-transpose image
-transverse transpose image
-trim Drop non-transformable edge blocks
Switches for advanced users:
-restart N Set restart in rows with or in blocks with B
-maxmemory N Maximum memory to use (in kbytes)
-outfile name Specify name for output file
-verbose or -debug Emit debug output
Switches for wizards:
-scans file Create multi-scan JPEG per script file
Read about crop and resize functions
here .
The utility in assembly under RedHat
some 18 Kb weighs.
It was not possible to measure adequately the speed of work, but according to my own feelings very quickly. :)
Maybe I still do not know what you use?