Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Resize pic on upload  (Read 16881 times)

0 Members and 1 Guest are viewing this topic.

clifflui

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
    • http://www.viperfusion.com
Resize pic on upload
« 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.
« Last Edit: April 06, 2005, 06:35:57 am by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Resize pic on upload
« Reply #1 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
Logged

clifflui

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
    • http://www.viperfusion.com
Resize pic on upload
« Reply #2 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.
Logged

freez

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Resize pic on upload
« Reply #3 on: February 28, 2004, 05:34:58 am »

That is were a tool like iBULC comes in handy. It will optional resize image images before upload. Try that out here: http://www.ibulc.com/demonstration/
Logged

phil

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
    • http://www.thematti.com
found a nice freeware
« Reply #4 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
Logged

Haelios

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
Resize pic on upload
« Reply #5 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.
Logged

hyperion

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 1317
  • - retired -
Resize pic on upload
« Reply #6 on: March 17, 2004, 05:04:35 am »

@Haelios:

Where's the patch?  :wink:
Logged
"Then, Fletch," that bright creature said to him, and the voice was very kind, "let's begin with level flight . . . ."

-Richard Bach, Jonathan Livingston Seagull

(http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png)

black1

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Resize pic on upload
« Reply #7 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:
Logged

Hal9000

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Resize pic on upload
« Reply #8 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
Logged

Hal9000

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Resize pic on upload
« Reply #9 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 ;)
Logged

RatKing

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 85
    • Personal website
Re: Resize pic on upload
« Reply #10 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
Logged

stcrim

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Resize pic on upload
« Reply #11 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
Logged

spaceman

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 16
    • Itomic Business Website Solutions
Re: Resize pic on upload
« Reply #12 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 ).
Logged
www.itomic.com - perth business website solutions

HighlanderBR

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Resize pic on upload
« Reply #13 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?
Logged

groan

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: Resize pic on upload
« Reply #14 on: July 31, 2004, 03:37:32 pm »

i was just going to ask...not working...!!!! :-\\
Logged

ytknows

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Resize pic on upload
« Reply #15 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.
Logged

Cisi

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 14
Re: Resize pic on upload
« Reply #16 on: April 09, 2005, 12:00:23 pm »

I agree , would be very nice to make working with 1-3-x .. very useful .
 ;)
Logged

sweeet

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Resize pic on upload
« Reply #17 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 ;)
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Resize pic on upload
« Reply #18 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.
Logged
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots
Pages: [1]   Go Up
 

Page created in 0.028 seconds with 19 queries.