Donations

Help support Pro_News and become a member of our Sponsors Group
The tip jar is at PayPal, but does not require a PayPal account
User Info
Wilkommen Unbekannt
Mitglieder:
Neuestes: Witewolf
Heute neu: 0
Gestern neu: 0
Gesamt: 151
Anwesende Nutzer:
Mitglieder: 0
Besucher: 41
Roboter: 3
Gesamt: 44
Wer ist wo?:
Besucher:Support Forums
Support Forums
Pro News Articles
Support Forums
Support Forums
Nedladdningar
Support Forums
Support Forums
Support Forums
Support Forums
Pro News Articles
Support Forums
Downloads
Support Forums
Pro News Articles
Téléchargement
Téléchargement
Support Forums
Pro News Articles
Pro News Articles
Support Forums
Pro News Articles
Support Forums
Pro News Articles
Support Forums
Pro News Articles
Pro News Articles
Pro News Articles
Pro News Articles
Support Forums
Téléchargement
Downloads
Mitt konto
Support Forums
Pro News Articles
Support Forums
Pro News Articles
Pro News Articles
Pro News Articles
Downloads
Support Forums
Roboter:Google > Pro News Articles
Baidu > Pro News Articles
YANDEX > Support Forums
Wer ist online:
Keine Mitglieder online!
Resize Large Coppermine Images on Upload
Resize Large Coppermine Images on Upload
Verfasst am: Sat Jan 22, 2011 5:53 pm
NOTE THAT THIS IS BETA CODE - REQUIRES TESTING BEFORE PRODUCTION USE
If you are like me you want to limit the maximum size of uploaded Coppermine images. 12MB images are just too big to display meaningfully.
But like me you have members who couldn't resize an image successfully if a valuable prize was offered!
So I've developed this simple patch to resize images on the fly during user upload in Coppermine. It is developed as an extension to the Max Image Dimension option in Pro_News. But it is not difficult to configure it to work without Pro_News - if you haven't yet been turned on to the benefits of Pro_News as THE module in your DragonflyCSM website. ![]()
As noted on DragonflyCMS.org if you are running DF 9.2.1 (vs some later release) then you must change line 34 of /includes/imaging/gd2.inc to:
if (CAN_MOD_INI) ini_set('memory_limit', '128M');
(128MB is most likely needed here, because we are dealing with larger target images sizes when resizing the original image.)
In /includes/coppermine/picmgmt.inc find on line 26:
global $db, $CONFIG, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL, $CPG_M_DIR;
and replace with:
global $db, $CONFIG, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL, $CPG_M_DIR, $MAIN_CFG;
In /includes/coppermine/picmgmt.inc find on line 43:
if (max($imginfo[0], $imginfo[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal) &&
and replace with: UPDATE - Improved version for this part below
if (max($imginfo[0], $imginfo[1]) > $MAIN_CFG['pro_news']['img_limit'] &&
!resize_image($src_file, $imginfo, $image, $MAIN_CFG['pro_news']['img_limit'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], $watermark)) {
unlink($thumb);
return false;
}
if (max($imginfo[0], $imginfo[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal) &&
If you use Pro_News this will resize the original image to comply with the Max Image Dimension in Config. If you do not have Pro_News installed, then you will need to go into phpMyAdmin, select the cms_config_custom file, and insert the following record:
cfg_name pro_news cfg_field img_limit cfg_value 800
where 800 can be any value, and represents the maximum height or width for an upload image before resizing kicks in. And after updating you will need to delete the config_MAIN_CFG.php file in your /cache folder for the update to take effect.
This should be sufficient, at least it works for me on 9.2.1.
I would be interested in hearing any feedback. Or appreciation. ![]()
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1
Zuletzt bearbeitet von layingback am Thu Aug 04, 2011 3:09 pm, insgesamt 2-mal bearbeitet

layingback- Site Admin

- Beiträge: 1229
- Dabei seit: Mar 18, 2006
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 3:02 pm
Just tried this. Tried to upload an image that is 2.11Mb and got a scrambled page after a couple of minutes wait with a message near the bottom of:
CMS Error /home/chantill/public_html/modules/coppermine/db_input.php line 360:
The size of the file you have uploaded is too large (maximum allowed is 2097152 KB) !
PHPinfo shows Memory_Limit as 32M which I guess comes from my php.ini file? It also shows upload_max_filesize as 10M and post_max_size as 55M.
The resize code in /includes/coppermine/picmgmt.inc looks like this. Is that right?
if (max($imginfo[0], $imginfo[1]) > $MAIN_CFG['pro_news']['img_limit'] &&
!resize_image($src_file, $imginfo, $image, $MAIN_CFG['pro_news']['img_limit'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], $watermark)) {
unlink($thumb);
return false;
}
if (max($imginfo[0], $imginfo[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal) &&
!resize_image($src_file, $imginfo, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], $watermark)) {
unlink($thumb);
return false;
}rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif- BetaTester

- Beiträge: 492
- Dabei seit: Aug 01, 2007
- Wohnort: Chantilly, France
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 3:42 pm
My patch does nothing for the php limit on 2MB uploads. Try with large (width, height) image which is not > 2MB.
Nano's post here purports to address this 2MB limit, but your settings already seem larger than his suggested changes, so ...
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Beiträge: 1229
- Dabei seit: Mar 18, 2006
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 3:54 pm
Hmm, odd. Not sure where the 2M figure is still coming from. I've not had a problem with larger images before...
rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif- BetaTester

- Beiträge: 492
- Dabei seit: Aug 01, 2007
- Wohnort: Chantilly, France
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 5:30 pm
What's your Max size for uploaded pictures (KB) in Coppermine > Config? 2048KB?
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Beiträge: 1229
- Dabei seit: Mar 18, 2006
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 5:48 pm
That was a rhetorical question wasn't it? ![]()
So that allowed me to upload it (took over a minute) - however it has set the max dimension to 2048 despite the fact that in PN the max dimension is set to 800 (it's 2048 in coppermine).
rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif- BetaTester

- Beiträge: 492
- Dabei seit: Aug 01, 2007
- Wohnort: Chantilly, France
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 5:57 pm
- rosbifSo that allowed me to upload it (took over a minute)
Never said that uploading the large version was ever a good idea ![]()
The code segment you pasted above looks right. You did include the $MAIN_CONFIG in global edit as well I trust? Because if it doesn't find PN entry it will default to CPG one (been there, done that!)
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Beiträge: 1229
- Dabei seit: Mar 18, 2006
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 6:02 pm
It's there
global $db, $CONFIG, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL, $CPG_M_DIR, $MAIN_CFG;
rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif- BetaTester

- Beiträge: 492
- Dabei seit: Aug 01, 2007
- Wohnort: Chantilly, France
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 6:29 pm
Not sure what is up then.
What size image (in px) did you start out with?
I've revised the code slightly, but this doesn’t affect the basic logic, just ensures that the intermediate/normal image is generated from the same original, not from the resized one (double jeopardy for image quality).
if (max($imginfo[0], $imginfo[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal) &&
!resize_image($src_file, $imginfo, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], $watermark)) {
unlink($thumb);
return false;
}
if (max($imginfo[0], $imginfo[1]) > $MAIN_CFG['pro_news']['img_limit'] &&
!resize_image($src_file, $imginfo, $image, $MAIN_CFG['pro_news']['img_limit'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], $watermark)) {
unlink($normal);
unlink($thumb);
return false;
}
I'm doing this on 9.2.1, specifically version 9.14 of picmgmt.inc
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Beiträge: 1229
- Dabei seit: Mar 18, 2006
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 7:27 pm
Same versions here. Have just tried again and it's resized it to 1090 x 800...
rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif- BetaTester

- Beiträge: 492
- Dabei seit: Aug 01, 2007
- Wohnort: Chantilly, France
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 9:49 pm
OK, assuming it was bigger originally, it's resized based on the smallest side ...
Don’t understand why it does this for you and enginama, when every image that I've done has adjusted based on the long side. (With both versions of the code. And I've tested with 11 unique images.)
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Beiträge: 1229
- Dabei seit: Mar 18, 2006
Re: Resize Large Coppermine Images on Upload
Verfasst am: Sun Jan 23, 2011 10:01 pm
Oh, oh, oh! What have you set 'Use dimension ( width or height or Max aspect for thumbnail )*' in CPG Config?
I have mine set to Max aspect, so it is checking both and resizing to the largest. I'm guessing you guys have it set to width (or height) and so it only handles that 1 case.
Can you try with Max aspect please? Just so we know...
I'm not sure it is possible to handle the other 2 cases easily, but I will take a look. Although I do think Max aspect is the way to go as an Admin ![]()
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Beiträge: 1229
- Dabei seit: Mar 18, 2006
Re: Resize Large Coppermine Images on Upload
Verfasst am: Mon Jan 24, 2011 12:35 pm
Looks to be working perfectly... It resized a large image to 800 x 600 (and seemed quicker on a bigger image too?).
So did the original upload not do this anyway from looking at the code?
rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif- BetaTester

- Beiträge: 492
- Dabei seit: Aug 01, 2007
- Wohnort: Chantilly, France
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst keine Dateien anhängen.
Du kannst Dateien herunterladen.
Alle Zeitangaben sind in GMT











