|
#1
|
||||
|
||||
|
Another auto resize hack
Hi,
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. INSTALL: 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. MODIFIED LINES: admin/options.php lines 72-92 : resize options form admin/index.php 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 DEVELOPMENT NOTES: 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. Romain |
|
#2
|
||||
|
||||
|
is EXIF data intact or it will be gone?
(in the next release you can do this with an addon not a mod)
__________________
Photoblog: http://pblog.raminia.com Powered by Pixelpost 1.7 |
|
#3
|
||||
|
||||
|
Try this toolbox for putting back the EXIF info:
http://www.ozhiker.com/electronics/pjmt/ suggesting: 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.
__________________
Photoblog: http://pblog.raminia.com Powered by Pixelpost 1.7 |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
||||
|
||||
|
Thx raminia, i gonna try.
|
|
#6
|
||||
|
||||
|
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
__________________
Photoblog: http://pblog.raminia.com Powered by Pixelpost 1.7 |
|
#7
|
||||
|
||||
|
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 : http://dominica.et.romain.free.fr/Au...injectEXIF.zip To install, unzip as is into admin folder. Run the SQL script with your mySQL admin tool. Hacks : Index.php is modified : Line 40 Calls to needed libraries from pjmt Code:
// Call PHP JPEG Metadata Toolkit library
require('pjmt/JPEG.php');
require('pjmt/EXIF.php');
Code:
$original_exif_data = get_EXIF_JPEG( $file ); Code:
$resized_jpeg_header = get_jpeg_header_data($resizedpath);
// Alter the EXIF data of the resized pix
$resized_jpeg_header = put_EXIF_JPEG( $original_exif_data, $resized_jpeg_header);
if ( FALSE == put_jpeg_header_data( $resizedpath, $resizedpath, $resized_jpeg_header ) ) {
// Writing of the new file didn't work - output error message
echo "Error - Failure to write new JPEG : $resizedpath <br>\n";
}
![]() This opens a popup with pjmt/getMetaData.php file (some light modifications from Example.php provided with the toolkit)
|
|
#8
|
||||
|
||||
|
wow!
I'll make an admin addon from it for the next release with preserving your credits!! That's great! thanks!
__________________
Photoblog: http://pblog.raminia.com Powered by Pixelpost 1.7 |
|
#9
|
||||
|
||||
|
Quote:
Thanks again.
__________________
Photoblog: http://pblog.raminia.com Powered by Pixelpost 1.7 |
|
#10
|
||||
|
||||
|
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, ...). |
| Post Reply |
| Thread Tools | |
|
|