I need my Normal_ to be 75% smaller then original I need my Normal_ to be 75% smaller then original
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

I need my Normal_ to be 75% smaller then original

Started by troublemaker, April 15, 2004, 09:33:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

troublemaker

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
Site Admin's @ coppermine kick much techie @$$

hyperion



    $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:
"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

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

troublemaker

Parse error: parse error in /home/clynefan/public_html/include/picmgmt.inc.php on line 53
Site Admin's @ coppermine kick much techie @$$

hyperion

Come on, troublemaker. I'm not doing all the work for you.  :wink:

Look at line 53.  What is there?
"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

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

troublemaker

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)
Site Admin's @ coppermine kick much techie @$$

hyperion

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.
"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

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

troublemaker

<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.3.0                                            //
// ------------------------------------------------------------------------- //
// Copyright &#40;C&#41; 2002,2003 Gregory DEMAR                                     //
// http&#58;//www.chezgreg.net/coppermine/                                       //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team                                        //
// &#40;http&#58;//coppermine.sf.net/team/&#41;                                          //
// 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         //
// &#40;at your option&#41; any later version.                                       //
// ------------------------------------------------------------------------- //

/*
$Id&#58; picmgmt.inc.php,v 1.10 2004/03/21 22&#58;21&#58;15 gaugau Exp $
*/

// Add a picture to an album
function add_picture&#40;$aid, $filepath, $filename, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '',$iwidth=0,$iheight=0&#41;
&#123;
    
global $CONFIG$ERROR$USER_DATA$PIC_NEED_APPROVAL;
    global 
$lang_errors;

    
$image $CONFIG['fullpath'&#93; . $filepath . $filename;
    
$normal $CONFIG['fullpath'&#93; . $filepath . $CONFIG['normal_pfx'&#93; . $filename;
    
$thumb $CONFIG['fullpath'&#93; . $filepath . $CONFIG['thumb_pfx'&#93; . $filename;

    
if &#40;!is_known_filetype&#40;$image&#41;&#41; &#123;
        
return false;
    &
#125; elseif &#40;is_image&#40;$filename&#41;&#41; &#123;
        
if &#40;!file_exists&#40;$thumb&#41;&#41; &#123;
            
if &#40;!resize_image&#40;$image, $thumb, $CONFIG['thumb_width'&#93;, $CONFIG['thumb_method'&#93;, $CONFIG['thumb_use'&#93;&#41;&#41;
                
return false;
        &
#125;
    
$imagesize getimagesize&#40;$image&#41;; 

    
$new_width = &#40;int&#41;&#40;&#40;$imagesize[0&#93;&#41;*&#40;1/4&#41;&#41;; 

    
$reduction_control 'wd'

    if &
#40;!file_exists&#40;$thumb&#41;&#41; 
        
if &#40;!resize_image&#40;$image, $thumb, $CONFIG['thumb_width'&#93;, $CONFIG['thumb_method'&#93;, $CONFIG['thumb_use'&#93;&#41;&#41; 
            
return false
        if &
#40;max&#40;$imagesize[0&#93;, $imagesize[1&#93;&#41; > $CONFIG['picture_width'&#93; && $CONFIG['make_intermediate'&#93; && !file_exists&#40;$normal&#41;&#41; 
            
if &#40;!resize_image&#40;$image, $normal, $new_width, $CONFIG['thumb_method'&#93;, $reduction_control&#41;&#41; 
                
return false
        &
#125;
                
    
&#125; else &#123;
        
$imagesize[0&#93; = $iwidth;
        
$imagesize[1&#93; = $iheight;
    
&#125;

    
$image_filesize filesize&#40;$image&#41;;
    
$total_filesize is_image&#40;$filename&#41; ? &#40;$image_filesize + &#40;file_exists&#40;$normal&#41; ? filesize&#40;$normal&#41; &#58; 0&#41; + filesize&#40;$thumb&#41;&#41; &#58; &#40;$image_filesize&#41;;


    // Test if disk quota exceeded
    
if &#40;!GALLERY_ADMIN_MODE && $USER_DATA['group_quota'&#93;&#41; &#123;
        
$result db_query&#40;"SELECT sum&#40;total_filesize&#41; FROM &#123;$CONFIG['TABLE_PICTURES'&#93;&#125;, &#123;$CONFIG['TABLE_ALBUMS'&#93;&#125; WHERE  &#123;$CONFIG['TABLE_PICTURES'&#93;&#125;.aid = &#123;$CONFIG['TABLE_ALBUMS'&#93;&#125;.aid AND category = '" . &#40;FIRST_USER_CAT + USER_ID&#41; . "'"&#41;;
        
$record mysql_fetch_array&#40;$result&#41;;
        
$total_space_used $record[0&#93;;
        
mysql_free_result&#40;$result&#41;;
        
if &#40;$total_space_used + $total_filesize > $USER_DATA['group_quota'&#93; << 10&#41; &#123;
            
@unlink&#40;$image&#41;;
            
if &#40;is_image&#40;$image&#41;&#41; &#123;
                
@unlink&#40;$normal&#41;;
                
@unlink&#40;$thumb&#41;;
            
&#125;
            
$msg strtr&#40;$lang_errors['quota_exceeded'&#93;, array&#40;'[quota&#93;' => &#40;$USER_DATA['group_quota'&#93;&#41;,
                
'[space&#93;' => &#40;$total_space_used >> 10&#41;&#41;&#41;;
            
cpg_die&#40;ERROR, $msg, __FILE__, __LINE__&#41;;
        
&#125;
    
&#125;
    // Test if picture requires approval
    
if &#40;GALLERY_ADMIN_MODE&#41; &#123;
        
$approved 'YES';
    &
#125; elseif &#40;!$USER_DATA['priv_upl_need_approval'&#93; && $category == FIRST_USER_CAT + USER_ID&#41; &#123;
        
$approved 'YES';
    &
#125; elseif &#40;!$USER_DATA['pub_upl_need_approval'&#93;&#41; &#123;
        
$approved 'YES';
    &
#125; else &#123;
        
$approved 'NO';
    &
#125;
    
$PIC_NEED_APPROVAL = &#40;$approved == 'NO'&#41;;
    // User ID is not recorded when in admin mode &#40;ie. for batch uploads&#41;
    
$user_id GALLERY_ADMIN_MODE &#58; USER_ID;
        
$username=$USER_DATA['user_name'&#93; ;
    
$query "INSERT INTO &#123;$CONFIG['TABLE_PICTURES'&#93;&#125; &#40;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&#41; VALUES &#40;'', '$aid', '" addslashes&#40;$filepath&#41; . "', '" . addslashes&#40;$filename&#41; . "', '$image_filesize', '$total_filesize', '&#123;$imagesize[0&#93;&#125;', '&#123;$imagesize[1&#93;&#125;', '" . time&#40;&#41; . "', '$user_id', '$username','$title', '$caption', '$keywords', '$approved', '$user1', '$user2', '$user3', '$user4', '$raw_ip', '$hdr_ip'&#41;";
    
$result db_query&#40;$query&#41;;

    
return $result;
&
#125;

define&#40;"GIS_GIF", 1&#41;;
define&#40;"GIS_JPG", 2&#41;;
define&#40;"GIS_PNG", 3&#41;;

/**
* resize_image&#40;&#41;
*
* 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&#40;$src_file, $dest_file, $new_size, $method, $thumb_use&#41;
&#123;
    
global $CONFIG$ERROR;
    global 
$lang_errors;

    
$imginfo getimagesize&#40;$src_file&#41;;
    
if &#40;$imginfo == null&#41;
        
return false;
        
// GD can only handle JPG & PNG images
    
if &#40;$imginfo[2&#93; != GIS_JPG && $imginfo[2&#93; != GIS_PNG && &#40;$method == 'gd1' || $method == 'gd2'&#41;&#41; &#123;
        
$ERROR $lang_errors['gd_file_type_err'&#93;;
        
return false;
    &
#125;
    // height/width
    
$srcWidth $imginfo[0&#93;;
    
$srcHeight $imginfo[1&#93;;
    
if &#40;$thumb_use == 'ht'&#41; &#123;
        
$ratio $srcHeight $new_size;
    &
#125; elseif &#40;$thumb_use == 'wd'&#41; &#123;
        
$ratio $srcWidth $new_size;
    &
#125; else &#123;
        
$ratio max&#40;$srcWidth, $srcHeight&#41; / $new_size;
    
&#125;
    
$ratio max&#40;$ratio, 1.0&#41;;
    
$destWidth = &#40;int&#41;&#40;$srcWidth / $ratio&#41;;
    
$destHeight = &#40;int&#41;&#40;$srcHeight / $ratio&#41;;
    // Method for thumbnails creation
    
switch &#40;$method&#41; &#123;
        
case "im" &#58;
            
if &#40;preg_match&#40;"#[A-Z&#93;&#58;|\\\\#Ai", __FILE__&#41;&#41; &#123;
                // get the basedir, remove '/include'
                
$cur_dir substr&#40;dirname&#40;__FILE__&#41;, 0, -8&#41;;
                
$src_file '"' $cur_dir '\\' strtr&#40;$src_file, '/', '\\'&#41; . '"';
                
$im_dest_file str_replace&#40;'%', '%%', &#40;'"' . $cur_dir . '\\' . strtr&#40;$dest_file, '/', '\\'&#41; . '"'&#41;&#41;;
            
&#125; else &#123;
                
$src_file escapeshellarg&#40;$src_file&#41;;
                
$im_dest_file str_replace&#40;'%', '%%', escapeshellarg&#40;$dest_file&#41;&#41;;
            
&#125;

            
$output = array&#40;&#41;;
            
$cmd "&#123;$CONFIG['impath'&#93;&#125;convert -quality &#123;$CONFIG['jpeg_qual'&#93;&#125; &#123;$CONFIG['im_options'&#93;&#125; -geometry &#123;$destWidth&#125;x&#123;$destHeight&#125; $src_file $im_dest_file";
            
exec &#40;$cmd, $output, $retval&#41;;

            
if &#40;$retval&#41; &#123;
                
$ERROR "Error executing ImageMagick - Return value&#58; $retval";
                if &
#40;$CONFIG['debug_mode'&#93;&#41; &#123;
                    // 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 &#58; <br /><font size=\"2\">" nl2br&#40;htmlspecialchars&#40;$cmd&#41;&#41; . "</font></div>";
                    
$ERROR .= "<br /><br /><div align=\"left\">The convert program said&#58;<br /><font size=\"2\">";
                    
$ERROR .= nl2br&#40;htmlspecialchars&#40;$output&#41;&#41;;
                    
$ERROR .= "</font></div>";
                &
#125;
                
@unlink&#40;$dest_file&#41;;
                
return false;
            &
#125;
            
break;

        case 
"gd1" &#58;
            
if &#40;!function_exists&#40;'imagecreatefromjpeg'&#41;&#41; &#123;
                
cpg_die&#40;CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__&#41;;
            
&#125;
            
if &#40;$imginfo[2&#93; == GIS_JPG&#41;
                
$src_img imagecreatefromjpeg&#40;$src_file&#41;;
            
else
                
$src_img imagecreatefrompng&#40;$src_file&#41;;
            
if &#40;!$src_img&#41; &#123;
                
$ERROR $lang_errors['invalid_image'&#93;;
                
return false;
            &
#125;
            
$dst_img imagecreate&#40;$destWidth, $destHeight&#41;;
            
imagecopyresized&#40;$dst_img, $src_img, 0, 0, 0, 0, $destWidth, &#40;int&#41;$destHeight, $srcWidth, $srcHeight&#41;;
            
imagejpeg&#40;$dst_img, $dest_file, $CONFIG['jpeg_qual'&#93;&#41;;
            
imagedestroy&#40;$src_img&#41;;
            
imagedestroy&#40;$dst_img&#41;;
            
break;

        case 
"gd2" &#58;
            
if &#40;!function_exists&#40;'imagecreatefromjpeg'&#41;&#41; &#123;
                
cpg_die&#40;CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__&#41;;
            
&#125;
            
if &#40;!function_exists&#40;'imagecreatetruecolor'&#41;&#41; &#123;
                
cpg_die&#40;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__&#41;;
            
&#125;
            
if &#40;$imginfo[2&#93; == GIS_JPG&#41;
                
$src_img imagecreatefromjpeg&#40;$src_file&#41;;
            
else
                
$src_img imagecreatefrompng&#40;$src_file&#41;;
            
if &#40;!$src_img&#41; &#123;
                
$ERROR $lang_errors['invalid_image'&#93;;
                
return false;
            &
#125;
            
$dst_img imagecreatetruecolor&#40;$destWidth, $destHeight&#41;;
            
imagecopyresampled&#40;$dst_img, $src_img, 0, 0, 0, 0, $destWidth, &#40;int&#41;$destHeight, $srcWidth, $srcHeight&#41;;
            
imagejpeg&#40;$dst_img, $dest_file, $CONFIG['jpeg_qual'&#93;&#41;;
            
imagedestroy&#40;$src_img&#41;;
            
imagedestroy&#40;$dst_img&#41;;
            
break;
    &
#125;
    // Set mode of uploaded picture
    
chmod&#40;$dest_file, octdec&#40;$CONFIG['default_file_mode'&#93;&#41;&#41;;
    // We check that the image is valid
    
$imginfo getimagesize&#40;$dest_file&#41;;
    
if &#40;$imginfo == null&#41; &#123;
        
$ERROR $lang_errors['resize_failed'&#93;;
        
@unlink&#40;$dest_file&#41;;
        
return false;
    &
#125; else &#123;
        
return true;
    &
#125;
&#125;
?>
Site Admin's @ coppermine kick much techie @$$

hyperion

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;
    }
&quot;Then, Fletch,&quot; that bright creature said to him, and the voice was very kind, &quot;let&#039;s begin with level flight . . . .&quot;

-Richard Bach, Jonathan Livingston Seagull

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

troublemaker

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
Site Admin's @ coppermine kick much techie @$$

hyperion

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.
&quot;Then, Fletch,&quot; that bright creature said to him, and the voice was very kind, &quot;let&#039;s begin with level flight . . . .&quot;

-Richard Bach, Jonathan Livingston Seagull

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

troublemaker

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.
Site Admin's @ coppermine kick much techie @$$

hyperion

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.  :)
&quot;Then, Fletch,&quot; that bright creature said to him, and the voice was very kind, &quot;let&#039;s begin with level flight . . . .&quot;

-Richard Bach, Jonathan Livingston Seagull

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

troublemaker

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
Site Admin's @ coppermine kick much techie @$$

hyperion

So the 75% was just to make it smaller, but it could have been any amount, such as 25% or 50%?
&quot;Then, Fletch,&quot; that bright creature said to him, and the voice was very kind, &quot;let&#039;s begin with level flight . . . .&quot;

-Richard Bach, Jonathan Livingston Seagull

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

troublemaker

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
Site Admin's @ coppermine kick much techie @$$

hyperion

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.
&quot;Then, Fletch,&quot; that bright creature said to him, and the voice was very kind, &quot;let&#039;s begin with level flight . . . .&quot;

-Richard Bach, Jonathan Livingston Seagull

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

troublemaker

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)
Site Admin's @ coppermine kick much techie @$$

troublemaker

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
Site Admin's @ coppermine kick much techie @$$

hyperion

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.
&quot;Then, Fletch,&quot; that bright creature said to him, and the voice was very kind, &quot;let&#039;s begin with level flight . . . .&quot;

-Richard Bach, Jonathan Livingston Seagull

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)