Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #1  
Old 07-08-2005, 01:34 PM
romain's Avatar
romain Offline
forum loafer
 
Join Date: Jul 2005
Location: Nice (France)
Posts: 7
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
Reply With Quote
  #2  
Old 07-08-2005, 03:31 PM
raminia's Avatar
raminia+ Offline
Team Pixelpost
 
Join Date: Jan 2005
Location: FL, US
Posts: 3,706
Send a message via Yahoo to raminia
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
Reply With Quote
  #3  
Old 07-08-2005, 04:52 PM
raminia's Avatar
raminia+ Offline
Team Pixelpost
 
Join Date: Jan 2005
Location: FL, US
Posts: 3,706
Send a message via Yahoo to raminia
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
Reply With Quote
  #4  
Old 07-08-2005, 05:14 PM
romain's Avatar
romain Offline
forum loafer
 
Join Date: Jul 2005
Location: Nice (France)
Posts: 7
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.
Reply With Quote
  #5  
Old 07-08-2005, 05:16 PM
romain's Avatar
romain Offline
forum loafer
 
Join Date: Jul 2005
Location: Nice (France)
Posts: 7
Thx raminia, i gonna try.
Reply With Quote
  #6  
Old 07-08-2005, 08:38 PM
raminia's Avatar
raminia+ Offline
Team Pixelpost
 
Join Date: Jan 2005
Location: FL, US
Posts: 3,706
Send a message via Yahoo to raminia
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
Reply With Quote
  #7  
Old 07-11-2005, 10:49 AM
romain's Avatar
romain Offline
forum loafer
 
Join Date: Jul 2005
Location: Nice (France)
Posts: 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');
Line 1125: Retrieve of the EXIF data of the original JPEG
Code:
$original_exif_data = get_EXIF_JPEG( $file );
Lines 1166: Reinjection of the original EXIF data into the resized picture:
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";
}
Once your image resized and downloaded, you can check the injected data with a new link included in index.php :

This opens a popup with pjmt/getMetaData.php file (some light modifications from Example.php provided with the toolkit)
Reply With Quote
  #8  
Old 07-11-2005, 11:46 AM
raminia's Avatar
raminia+ Offline
Team Pixelpost
 
Join Date: Jan 2005
Location: FL, US
Posts: 3,706
Send a message via Yahoo to raminia
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
Reply With Quote
  #9  
Old 07-11-2005, 11:51 AM
raminia's Avatar
raminia+ Offline
Team Pixelpost
 
Join Date: Jan 2005
Location: FL, US
Posts: 3,706
Send a message via Yahoo to raminia
Quote:
Originally Posted by raminia
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
btw, this mod has to many php files. It may be more than whole default php files of pp. The http://www.vinayras.com/projects/phpexifrw/phpExifDocs/ I used was very simple and small but the EXIF was not valid. I opened the file with Photoshop ans 'saved as' a new file and the exif become valid! I think the way phpexifrw does it could be fixed. Meanwhile to re-inject the EXIF info there is no need to have the whole makernotes (I think). Maybe some of the files are redundant. I'll check it at home.

Thanks again.
__________________
Photoblog: http://pblog.raminia.com Powered by Pixelpost 1.7
Reply With Quote
  #10  
Old 07-11-2005, 12:05 PM
romain's Avatar
romain Offline
forum loafer
 
Join Date: Jul 2005
Location: Nice (France)
Posts: 7
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, ...).
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 06:05 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs