Another auto resize hack
here is the hack for PixelPost V1.4.1 i have done for my site so as to avoid using an image editor tool to resize the pix before uploading it.
It allows resizing the width or height of the image with parameters set in the options panel.
Download the zip file from http://dominica.et.romain.free.fr/AutoResizeImage.zip
Unzip it at the root of your PixelPost site. It will override admin/index.php and admin/options.php files. Upload them with your FTP client.
If you have changed the prefix of the pixelpost tables, you have to edit the name og the config table (by default pixelpost_config). Run the script with your Mysql admin tool (Most of the time, PHPMyAdmin)
HOW TO USE IT:
In the options panel, a new part is added : AUTO RESIZING OF UPLOADED IMAGES
You can activate the hack (by default, no).
You can set the max limit your image shall have (by default 600 pixels, either width or height), and the compression rate for JPG pix (by default 80% - this rate is used to compress the picture. The smaller this rate is, the lightest your image is but the poorer the quality is).
Once configured, just upload images as usual with New Image.
HOW IT WORKS:
When you upload an image, the hack checks if the width or height are bigger than the configured size limit. If yes, then the resize function is called.
The longest side of the image is resized according to the limit,
the other side is resized according to the image ratio.
lines 72-92 : resize options form
lines 420-434 : main call to the resizeImage function.
lines 871-873 : treatment of the options.php form, storage of the parameters into the config table
lines 1050-1122 : resizeImage function
It might be interesting to set different values to limit width and height.
I haven't thought yet of such a feature as the longest side is enough for me for the moment. But i guess that it should go through a double treatment width and then height.
I hope you will enjoy.
is EXIF data intact or it will be gone?
(in the next release you can do this with an addon not a mod)
Try this toolbox for putting back the EXIF info:
1 - read exif info from the original file.
2 - resize the file
3 - read the header information of the resized file
4 - put the original EXIF into the new header of the resized file
5 - put the modified header information of the resized file back into it.
To be honest, i don't know, as i don't use the EXIF data from my camera.
After tests on my images, i can retrieve the exif data related to FILE and COMPUTED formats. Thx to tell me if all the data are saved.
I am pretty sure that imagecopyresampled, the GD function i use to resize resets the EXIF data related to cam. For me, it is not an issue. Before that, i was resizing my pix with ACDSee and the metadata were lost while editing.
I know how to retrieve the EXIF data from a picture with GD, i don't know how to insert data into a picture. If such a method exists, then, the exif data retrieved before the resizing can be reinjected after resizing. It is a way to solve this.
Thx raminia, i gonna try.
I've done this with http://www.vinayras.com/projects/phpexifrw/phpExifDocs/ but the written EXIF info is not valid. ACDsee underestand it but EXIFER and my other exif program does not recognize it. It seems the imagecopyresampled has added some additional comments that exif programs does not like them or something else;)
EXIF Info reinjected into the JPEG
I have used the PHP JPEG Metadata Toolkit as suggested by Raminia.
The EXIF information from the original JPEG picture, ie before resizing it, is reinjected into the resized picture.
This injection is limited to JPEG and EXIF data. I do not reinject the comments or origina intrisic data.
New zip including the autoresize modifications and the pjmt toolkit delivery can be found here :
To install, unzip as is into admin folder.
Run the SQL script with your mySQL admin tool.
Index.php is modified :
Line 40 Calls to needed libraries from pjmt
This opens a popup with pjmt/getMetaData.php file (some light modifications from Example.php provided with the toolkit)
I'll make an admin addon from it for the next release with preserving your credits!!
That's great! thanks!
For sure the number of files can be optimized, and even the number of lines. I took the delivery from toolkit as is, with no modifications.
Yet, as I used the toolkit only to retrieve JPG header and EXIF specific functions, many of the other functions are useless (jfif, photoshop, ...).
|All times are GMT. The time now is 01:00 AM.|
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.