forum.coppermine-gallery.net

Support => Older/other versions => cpg1.2 Standalone Support => Topic started by: clifflui on October 13, 2003, 07:03:21 am

Title: Resize pic on upload
Post by: clifflui on October 13, 2003, 07:03:21 am
We all know that we usually have to resize a picture (e.g. 1280x1024) to a reasonable size (e.g. 600x480) before uploading via FTP or web interface.

Would it not be great to have an option checkbox in the web interface to resize (by limiting height/width or percentage magnification) the image that one plans to upload so we do not have to hassle with photoshop?

As for batch uploads, you can have an option to resize all by limiting dimensions or by percentage.
Title: Resize pic on upload
Post by: Joachim Müller on October 13, 2003, 08:22:58 am
There's already a tool integrated in version 1.2.0 (that will come out soon) that can drop the fullsize pics after upload (freeing a lot of webspace). We've also already considered the feature you're suggesting for a future version of Coppermine (a resize of the uploaded picture to a max dimension the site admin has set in config).
At the moment, site admins are encouraged to upload multiple pics by ftp (with the pics already resized to the fnal version they want it to appear in), using the batch-add function. The upload by browser interface is only recommended for "normal" users who can't have ftp access; most of them hardly know how to resize a pic properly before uploading.
In other words: we're working on it... :wink:

GauGau
Title: Resize pic on upload
Post by: clifflui on October 13, 2003, 10:29:31 am
Ah, GauGau, nice to see coppermine up again. I guess I have to wait until version 2 comes out then. Thanks a bunch.
Title: Resize pic on upload
Post by: freez on February 28, 2004, 05:34:58 am
That is were a tool like iBULC (http://www.ibulc.com) comes in handy. It will optional resize image images before upload. Try that out here: http://www.ibulc.com/demonstration/ (http://www.ibulc.com/demonstration/)
Title: found a nice freeware
Post by: phil on March 15, 2004, 08:17:58 pm
I finally found a nice freeware, which resizes and also renames the pictures with the EXIF data.
http://www.unidreamtech.com/  8)
Just download and install it

Have fun and enjoy life...
phil
Title: Resize pic on upload
Post by: Haelios on March 16, 2004, 10:28:37 pm
I'm just a newbie so I can't seem to understand why it is taking so long to add the full-sized-image-auto-resize feature. I mean, there is already code that creates the thumbnails and the normal images.
Title: Resize pic on upload
Post by: hyperion on March 17, 2004, 05:04:35 am
@Haelios:

Where's the patch?  :wink:
Title: Resize pic on upload
Post by: black1 on April 02, 2004, 03:13:37 am
I came up with my own quick hack for automatic resize on upload, which I'd like to share. Keep in mind it only works with GD version 2.x and on jpeg images:

edit db_input.php
find
Code: [Select]
chmod($uploaded_pic, octdec($CONFIG['default_file_mode']));
and insert this right below it
Code: [Select]
if (eregi ("\.jpe?g$", $uploaded_pic)) {
        $imgOld = imagecreatefromjpeg($uploaded_pic);
        $width = imagesx($imgOld);
        $height = imagesy($imgOld);
        if ($width > $CONFIG['picture_width']) {
                $height = ($CONFIG['picture_width']/$width)*$height;
                $width = $CONFIG['picture_width'];
                $imgNew = ImageCreateTrueColor($width,$height);    //requires GD 2.0
                ImageCopyResampled($imgNew,$imgOld,0,0,0,0,$width,$height,imagesx($imgOld),imagesy($imgOld));    //requires GD 2.0
                ImageJpeg($imgNew,$uploaded_pic);
                Imagedestroy($imgNew);
        }
}

enjoy   :wink:
Title: Re: Resize pic on upload
Post by: Hal9000 on May 20, 2004, 06:32:31 pm
Interesting code.
Hhowever, it's resizing pictures to the limit set for intermediate pictures (in my case 400).
I modified the code a bit to work with vertical pictures too (height>width) and changed the 'picture_width' value with 'max_upl_width_height' which is set to 800, so I am supposed to get 800x600 or 600x800 pictures, depending on the case.
However, pictures are still generated using 400 pixels not 800, i don't understand why.
Can anybody look into this? Here's the code:

Code: [Select]
// Resize picture automatically if it's too big - added by Hal9000
if (eregi ("\.jpe?g$", $uploaded_pic)) {
   $imgOld = imagecreatefromjpeg($uploaded_pic);
   $width = imagesx($imgOld);
   $height = imagesy($imgOld);
   if ($width >= $height && $width > $CONFIG['max_upl_width_height']) {
  $height = ($CONFIG['max_upl_width_height']/$width)*$height;
  $width = $CONFIG['max_upl_width_height'];
  $imgNew = ImageCreateTrueColor($width,$height);    //requires GD 2.0
  ImageCopyResampled($imgNew,$imgOld,0,0,0,0,$width,$height,imagesx($imgOld),imagesy($imgOld));    //requires GD 2.0
  ImageJpeg($imgNew,$uploaded_pic);
  Imagedestroy($imgNew);
   }
   if ($width < $height && $height > $CONFIG['max_upl_width_height']) {
  $width = ($CONFIG['max_upl_width_height']/$height)*$width;
  $height = $CONFIG['max_upl_width_height'];
  $imgNew = ImageCreateTrueColor($width,$height);    //requires GD 2.0
  ImageCopyResampled($imgNew,$imgOld,0,0,0,0,$width,$height,imagesx($imgOld),imagesy($imgOld));    //requires GD 2.0
  ImageJpeg($imgNew,$uploaded_pic);
  Imagedestroy($imgNew);
   }
}


Thanks!
hal
Title: Re: Resize pic on upload
Post by: Hal9000 on May 20, 2004, 06:52:02 pm
I'm an idiot, WinSCP got disconnected and I didn't notice, so i was saving the php file to nowhere and it didn't update hehe...
My modified code works wonderfully, I recommend it!!!
It resizes correctly both horizontal and vertical images, using the "Max width or height for uploaded pictures (pixels)" setting from the config.
Greetings! And thanks to black1 of course ;)
Title: Re: Resize pic on upload
Post by: RatKing on May 28, 2004, 05:07:45 pm
An other solution to the same problem (it just doesn't change batch added pictures...)

http://forum.coppermine-gallery.net/index.php?topic=6281.0
Title: Re: Resize pic on upload
Post by: stcrim on June 22, 2004, 04:21:31 am
I'm using ImageMagick - has anyone created a hack that will resize using it on upload?

Steve
Title: Re: Resize pic on upload
Post by: spaceman on July 02, 2004, 06:01:13 pm
I'm using ImageMagick - has anyone created a hack that will resize using it on upload?

Steve

http://www.imagemagick.org/www/mogrify.html

I'm a coppermine newbie, but a semi-ex php/mysql programmer, and we've been using the ImageMagick mogrify command to automatically resize user uploaded jpegs in our CMS for about 3 years now. For someone who knows ImageMagick code this should be child's play :-)

I'd seriously like to see the 'intermediate + thumbnails file being kept the and the user's original (large) file discarded (as per this forum member: http://forum.coppermine-gallery.net/index.php?topic=6206.0 ).
Title: Re: Resize pic on upload
Post by: HighlanderBR on July 28, 2004, 04:58:54 am
Code: [Select]
// Resize picture automatically if it's too big - added by Hal9000
if (eregi ("\.jpe?g$", $uploaded_pic)) {
   $imgOld = imagecreatefromjpeg($uploaded_pic);
   $width = imagesx($imgOld);
   $height = imagesy($imgOld);
   if ($width >= $height && $width > $CONFIG['max_upl_width_height']) {
  $height = ($CONFIG['max_upl_width_height']/$width)*$height;
  $width = $CONFIG['max_upl_width_height'];
  $imgNew = ImageCreateTrueColor($width,$height);    //requires GD 2.0
  ImageCopyResampled($imgNew,$imgOld,0,0,0,0,$width,$height,imagesx($imgOld),imagesy($imgOld));    //requires GD 2.0
  ImageJpeg($imgNew,$uploaded_pic);
  Imagedestroy($imgNew);
   }
   if ($width < $height && $height > $CONFIG['max_upl_width_height']) {
  $width = ($CONFIG['max_upl_width_height']/$height)*$width;
  $height = $CONFIG['max_upl_width_height'];
  $imgNew = ImageCreateTrueColor($width,$height);    //requires GD 2.0
  ImageCopyResampled($imgNew,$imgOld,0,0,0,0,$width,$height,imagesx($imgOld),imagesy($imgOld));    //requires GD 2.0
  ImageJpeg($imgNew,$uploaded_pic);
  Imagedestroy($imgNew);
   }
}


Anybody know how make this code work with 1.3 version?
Title: Re: Resize pic on upload
Post by: groan on July 31, 2004, 03:37:32 pm
i was just going to ask...not working...!!!! :-\\
Title: Re: Resize pic on upload
Post by: ytknows on April 05, 2005, 11:05:29 pm
hate to bump this old thread, but if anyone could modify this to work with 1.3.x, that'd be great.
Title: Re: Resize pic on upload
Post by: Cisi on April 09, 2005, 12:00:23 pm
I agree , would be very nice to make working with 1-3-x .. very useful .
 ;)
Title: Re: Resize pic on upload
Post by: sweeet on June 13, 2005, 08:44:55 pm
Yeah please make this Hack available for 1.3.x
Anyone without unlimited traffic will thank you ;)
Title: Re: Resize pic on upload
Post by: kegobeer on June 14, 2005, 01:13:58 am
Resizing during the upload process has been incorportated into 1.4, but will not be reverse engineered for 1.3.x.