photo rename and resize

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
drascom
Posts: 16
Joined: 2013-04-20 16:54

photo rename and resize

Post by drascom » 2013-08-03 21:21

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.

drascom
Posts: 16
Joined: 2013-04-20 16:54

Re: photo rename and resize

Post by drascom » 2013-08-09 23:01

which file i have to edit before upload? help please

User avatar
a.gneady
Site Admin
Posts: 1287
Joined: 2012-09-27 14:46
Contact:

Re: photo rename and resize

Post by a.gneady » 2013-08-13 15:11

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.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

drascom
Posts: 16
Joined: 2013-04-20 16:54

Re: photo rename and resize

Post by drascom » 2013-08-14 09:07

thank you..

drascom
Posts: 16
Joined: 2013-04-20 16:54

Re: photo rename and resize

Post by drascom » 2013-08-14 11:04

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.

drascom
Posts: 16
Joined: 2013-04-20 16:54

Re: photo rename and resize

Post by drascom » 2013-09-08 23:44

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 ?

TheNoLifer
Veteran Member
Posts: 67
Joined: 2015-06-06 12:10

Re: photo rename and resize

Post by TheNoLifer » 2015-06-09 19:46

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!

TheNoLifer
Veteran Member
Posts: 67
Joined: 2015-06-06 12:10

Re: photo rename and resize

Post by TheNoLifer » 2015-06-16 23:08

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.

Post Reply