OK I understand that I may need to edit my picmgmt.inc.php
but I am trying to be brave
any one care to tell me where I can edit the script to make this happen
$imagesize = getimagesize($image);
$new_width = (int)(($imagesize[0])*(3/4));
$reduction_control = 'wd';
if (!file_exists($thumb))
if (!resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
return false;
if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal))
if (!resize_image($image, $normal, $new_width, $CONFIG['thumb_method'], $reduction_control))
return false;
:wink:
Parse error: parse error in /home/clynefan/public_html/include/picmgmt.inc.php on line 53
Come on, troublemaker. I'm not doing all the work for you. :wink:
Look at line 53. What is there?
50 return false;
51 }
52
53 } else {
54 $imagesize[0] = $iwidth;
and when I took out the space I got an error in line 52
sorry it took me a while to count the lines (yes I said count the lines)
Oh, dear. You poor soul. :)
Use Notepad or an equivalent text editor. Click Edit -> Goto. Then enter the line number or read the line number.
You've got a bracket problem, so go ahead and post the entire file here so we can look at what is missing.
<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.3.0 //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2003 Gregory DEMAR //
// http://www.chezgreg.net/coppermine/ //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team //
// (http://coppermine.sf.net/team/) //
// see /docs/credits.html for details //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// ------------------------------------------------------------------------- //
/*
$Id: picmgmt.inc.php,v 1.10 2004/03/21 22:21:15 gaugau Exp $
*/
// Add a picture to an album
function add_picture($aid, $filepath, $filename, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '',$iwidth=0,$iheight=0)
{
global $CONFIG, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL;
global $lang_errors;
$image = $CONFIG['fullpath'] . $filepath . $filename;
$normal = $CONFIG['fullpath'] . $filepath . $CONFIG['normal_pfx'] . $filename;
$thumb = $CONFIG['fullpath'] . $filepath . $CONFIG['thumb_pfx'] . $filename;
if (!is_known_filetype($image)) {
return false;
} elseif (is_image($filename)) {
if (!file_exists($thumb)) {
if (!resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
return false;
}
$imagesize = getimagesize($image);
$new_width = (int)(($imagesize[0])*(1/4));
$reduction_control = 'wd';
if (!file_exists($thumb))
if (!resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
return false;
if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal))
if (!resize_image($image, $normal, $new_width, $CONFIG['thumb_method'], $reduction_control))
return false;
}
} else {
$imagesize[0] = $iwidth;
$imagesize[1] = $iheight;
}
$image_filesize = filesize($image);
$total_filesize = is_image($filename) ? ($image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb)) : ($image_filesize);
// Test if disk quota exceeded
if (!GALLERY_ADMIN_MODE && $USER_DATA['group_quota']) {
$result = db_query("SELECT sum(total_filesize) FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT + USER_ID) . "'");
$record = mysql_fetch_array($result);
$total_space_used = $record[0];
mysql_free_result($result);
if ($total_space_used + $total_filesize > $USER_DATA['group_quota'] << 10) {
@unlink($image);
if (is_image($image)) {
@unlink($normal);
@unlink($thumb);
}
$msg = strtr($lang_errors['quota_exceeded'], array('[quota]' => ($USER_DATA['group_quota']),
'[space]' => ($total_space_used >> 10)));
cpg_die(ERROR, $msg, __FILE__, __LINE__);
}
}
// Test if picture requires approval
if (GALLERY_ADMIN_MODE) {
$approved = 'YES';
} elseif (!$USER_DATA['priv_upl_need_approval'] && $category == FIRST_USER_CAT + USER_ID) {
$approved = 'YES';
} elseif (!$USER_DATA['pub_upl_need_approval']) {
$approved = 'YES';
} else {
$approved = 'NO';
}
$PIC_NEED_APPROVAL = ($approved == 'NO');
// User ID is not recorded when in admin mode (ie. for batch uploads)
$user_id = GALLERY_ADMIN_MODE ? 0 : USER_ID;
$username=$USER_DATA['user_name'] ;
$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip) VALUES ('', '$aid', '" . addslashes($filepath) . "', '" . addslashes($filename) . "', '$image_filesize', '$total_filesize', '{$imagesize[0]}', '{$imagesize[1]}', '" . time() . "', '$user_id', '$username','$title', '$caption', '$keywords', '$approved', '$user1', '$user2', '$user3', '$user4', '$raw_ip', '$hdr_ip')";
$result = db_query($query);
return $result;
}
define("GIS_GIF", 1);
define("GIS_JPG", 2);
define("GIS_PNG", 3);
/**
* resize_image()
*
* Create a file containing a resized image
*
* @param $src_file the source file
* @param $dest_file the destination file
* @param $new_size the size of the square within which the new image must fit
* @param $method the method used for image resizing
* @return 'true' in case of success
*/
function resize_image($src_file, $dest_file, $new_size, $method, $thumb_use)
{
global $CONFIG, $ERROR;
global $lang_errors;
$imginfo = getimagesize($src_file);
if ($imginfo == null)
return false;
// GD can only handle JPG & PNG images
if ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && ($method == 'gd1' || $method == 'gd2')) {
$ERROR = $lang_errors['gd_file_type_err'];
return false;
}
// height/width
$srcWidth = $imginfo[0];
$srcHeight = $imginfo[1];
if ($thumb_use == 'ht') {
$ratio = $srcHeight / $new_size;
} elseif ($thumb_use == 'wd') {
$ratio = $srcWidth / $new_size;
} else {
$ratio = max($srcWidth, $srcHeight) / $new_size;
}
$ratio = max($ratio, 1.0);
$destWidth = (int)($srcWidth / $ratio);
$destHeight = (int)($srcHeight / $ratio);
// Method for thumbnails creation
switch ($method) {
case "im" :
if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) {
// get the basedir, remove '/include'
$cur_dir = substr(dirname(__FILE__), 0, -8);
$src_file = '"' . $cur_dir . '\\' . strtr($src_file, '/', '\\') . '"';
$im_dest_file = str_replace('%', '%%', ('"' . $cur_dir . '\\' . strtr($dest_file, '/', '\\') . '"'));
} else {
$src_file = escapeshellarg($src_file);
$im_dest_file = str_replace('%', '%%', escapeshellarg($dest_file));
}
$output = array();
$cmd = "{$CONFIG['impath']}convert -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} -geometry {$destWidth}x{$destHeight} $src_file $im_dest_file";
exec ($cmd, $output, $retval);
if ($retval) {
$ERROR = "Error executing ImageMagick - Return value: $retval";
if ($CONFIG['debug_mode']) {
// Re-execute the command with the backtit operator in order to get all outputs
// will not work is safe mode is enabled
$output = `$cmd 2>&1`;
$ERROR .= "<br /><br /><div align=\"left\">Cmd line : <br /><font size=\"2\">" . nl2br(htmlspecialchars($cmd)) . "</font></div>";
$ERROR .= "<br /><br /><div align=\"left\">The convert program said:<br /><font size=\"2\">";
$ERROR .= nl2br(htmlspecialchars($output));
$ERROR .= "</font></div>";
}
@unlink($dest_file);
return false;
}
break;
case "gd1" :
if (!function_exists('imagecreatefromjpeg')) {
cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__);
}
if ($imginfo[2] == GIS_JPG)
$src_img = imagecreatefromjpeg($src_file);
else
$src_img = imagecreatefrompng($src_file);
if (!$src_img) {
$ERROR = $lang_errors['invalid_image'];
return false;
}
$dst_img = imagecreate($destWidth, $destHeight);
imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight);
imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);
imagedestroy($src_img);
imagedestroy($dst_img);
break;
case "gd2" :
if (!function_exists('imagecreatefromjpeg')) {
cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__);
}
if (!function_exists('imagecreatetruecolor')) {
cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support GD version 2.x, please switch to GD version 1.x on the config page', __FILE__, __LINE__);
}
if ($imginfo[2] == GIS_JPG)
$src_img = imagecreatefromjpeg($src_file);
else
$src_img = imagecreatefrompng($src_file);
if (!$src_img) {
$ERROR = $lang_errors['invalid_image'];
return false;
}
$dst_img = imagecreatetruecolor($destWidth, $destHeight);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight);
imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);
imagedestroy($src_img);
imagedestroy($dst_img);
break;
}
// Set mode of uploaded picture
chmod($dest_file, octdec($CONFIG['default_file_mode']));
// We check that the image is valid
$imginfo = getimagesize($dest_file);
if ($imginfo == null) {
$ERROR = $lang_errors['resize_failed'];
@unlink($dest_file);
return false;
} else {
return true;
}
}
?>
You forgot to mention you were using 1.3. It makes a difference. :wink:
if (!is_known_filetype($image)) {
return false;
} elseif (is_image($filename)) {
if (!file_exists($thumb)) {
if (!resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
return false;
}
$imagesize = getimagesize($image);
$new_width = (int)(($imagesize[0])*(3/4)); // Here
$reduction_control = 'wd'; // And here, and in the resize_image call below.
if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal)) {
if (!resize_image($image, $normal, $new_width, $CONFIG['thumb_method'], $reduction_control))
return false;
}
} else {
$imagesize[0] = $iwidth;
$imagesize[1] = $iheight;
}
OK that worked great Hun
only one thing its not giving me the original again
can I just delete original in admin tools to fix that?
and thank you so so so so so so much
Quoteonly one thing its not giving me the original again
can I just delete original in admin tools to fix that?
What do you mean? You'll have to describe the behavior more clearly.
(what you were expecting vs. what you are getting)
Also, the current changes will only reduce to 75% if the picture exceeds the specified width in the Config Console. If you want it to happen all the time, you will need to make a few more changes.
sorry I'm so used to being negative
its giving me the original and I don't want it
if I delete the original via admin tools will that make it only the thumb and normal accessible to users?
I changed it to 1/4 I thought 3/4 was smaller (told you I'm not the brightest bulb) will this fix what your talking about --->
QuoteAlso, the current changes will only reduce to 75% if the picture exceeds the specified width in the Config Console. If you want it to happen all the time, you will need to make a few more changes.
You can delete originals using the Batch resize tool. Changing the ratio from 3/4 to 1/4 won't solve the issue I'm talking about, but the issue may be immaterial depending on the purpose of this modification.
Before we go any further, perhaps you ought to tell me your overall goal. There may be better ways to do what you want.
Give me the big picture. :)
I have really big pictures and I want to show others the thumb and medium
I want to keep original to myself for users who want to buy or bribe me for my better quality images
So the 75% was just to make it smaller, but it could have been any amount, such as 25% or 50%?
bingo new best friend of mine
I just wanted a smaller image and I picked a number out of my hat
isn't it weird how bigger numbers don't make smaller images?
just want more control over images i stay relatively sober to take
Well, then that was a fun exercise, but it was totally unecessary. :lol:
Undo the changes to your picmgmt.inc file. Then go to the Config console. Set the normal/intermediate picture width to a sufficiently small size, i.e. 300 px. Then set the thumb method to max aspect. This will ensure that the largest dimension of an intermediate is not larger than 300 pixels.
You have two options when it comes to disposing of the originals. You can do it manually after adding images by running the Batch Resize 'Delete originals' option (be sure to check the beta board for the update for this function), or you can change picmgmt.inc to automatically remove the image after the resizing is done. The automatic option requires some tinkering in other files, though.
well I think we both know I like the easy way out do I'll be taking the unediting option Bob for $200
Thank you and good night
you have been a great source of info proving your team kicks ass
(and may need better sleep habits)
nope wait a minute
Home > RCPM 2004 > Smith's Olde Bar, Atlanta, Georgia (RCPM 2004) > RCPM
everything was fine till I started to delete the originals
but i need sleep
Get some sleep. Then remember what I told you about getting the latest version (util.php). There's a bug in the older version that deletes the normals instead of the originals. Restore your normals by running the batch resize for normals. Then delete the originals.