Page 1 of 1

photo rename and resize

Posted: 2013-08-03 21:21
by drascom
i wanna resize photos to save my disk space and rename files with entered data with form is there easy way or code for this.

Re: photo rename and resize

Posted: 2013-08-09 23:01
by drascom
which file i have to edit before upload? help please

Re: photo rename and resize

Posted: 2013-08-13 15:11
by a.gneady
This is an abstract from the code in the generated "categories_dml.php" file from the Northwind demo (at http://bigprof.com/demo):

Code: Select all

$data['Picture'] = PrepareUploadedFile('Picture', 204800,'jpg|jpeg|gif|png', false, '');
if($data['Picture']) createThumbnail($data['Picture'], getThumbnailSpecs('categories', 'Picture', 'tv'));
if($data['Picture']) createThumbnail($data['Picture'], getThumbnailSpecs('categories', 'Picture', 'dv'));
This code is responsible for handling the uploaded image and then creating thumbnails for it. You could resize the uploaded image by modifying the code to read:

Code: Select all

$data['Picture'] = PrepareUploadedFile('Picture', 204800,'jpg|jpeg|gif|png', false, '');
if($data['Picture']) createThumbnail($data['Picture'], array('width' => 750, 'height' => 750, 'identifier' => ''));
if($data['Picture']) createThumbnail($data['Picture'], getThumbnailSpecs('categories', 'Picture', 'tv'));
if($data['Picture']) createThumbnail($data['Picture'], getThumbnailSpecs('categories', 'Picture', 'dv'));
The second line in the modified code above resizes the uploaded image to fit in a 750x750 box (retaining the aspect ratio with no distortion) .. I haven't tested this modification, so give it a try and let me know if it doesn't work.

Re: photo rename and resize

Posted: 2013-08-14 09:07
by drascom
thank you..

Re: photo rename and resize

Posted: 2013-08-14 11:04
by drascom
it's not effect original uploaded file,still same resolution,
also i add " ini_set('memory_limit', '128m')" to thumbnail.php and form_view.php now i can see resized thumbnails but still lack of resizing original pics.

Re: photo rename and resize

Posted: 2013-09-08 23:44
by drascom
i try to implement https://github.com/blueimp/jQuery-File-Upload for resizing pictures before uploading but my knowledge not enough to finish it.
i need some samples about it. any help please ?

Re: photo rename and resize

Posted: 2015-06-09 19:46
by TheNoLifer
Sorry to dredge this old topic back up, but I'd also be very interested to get this working. Spent a bit of time on it today, couldn't get the example to work - adding;

if($data['Picture']) createThumbnail($data['Picture'], array('width' => 750, 'height' => 750, 'identifier' => ''));

Replacing the relevant fields with my own particulars. It still uploaded the file at the original size, unfortunately.

Would appreciate your input!

Re: photo rename and resize

Posted: 2015-06-16 23:08
by TheNoLifer
I sidestepped my issue by modifying the image links to open in a new tab, rather than the light box. The need to resize becomes less of an issue.

Will revisit this functionality in the future though.