Integrating GD Library with Coppermine? Integrating GD Library with Coppermine?
 

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

Main Menu

Integrating GD Library with Coppermine?

Started by Frink, August 08, 2007, 07:48:40 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Frink

Is it possible to integrate the GD Library with Coppermine?

Here is the link to their site if it helps http://www.libgd.org/Main_Page

If it is possible to integrate the GD Library with Coppermine I would greatly appreciate any help.


Sami

Coppermine already using GD library to manipulate pictures
I don't know which type of integration you are looking for ???
‍I don't answer to PM with support question
Please post your issue to related board

Frink

Well I want to be able to update the GD Library with the up-to-date version and I don't know how to use GD's commands.   Here are the commands/codes I want to use http://search.cpan.org/~burak/GD-Thumbnail-1.10/lib/GD/Thumbnail.pm#create

Joachim Müller

Support for GD needs to be compiled into PHP - that's not something a web-driven app like coppermine can do. If you don't have GD available on your server, you'll need to talk to your webhost. As Sami suggested, Coppermine already uses GD, so your question doesn't apply. Marking this thread as "invalid" and moving it accordingly, as your question is not related to bridging. Coppermine is using the GD library to create the thumbnails and intermediate-sized images.
Please read the FAQ.

Frink

I should clarify this question.  I want to use these commands with Coppermine.  http://search.cpan.org/~burak/GD-Thumbnail-1.10/lib/GD/Thumbnail.pm.

Quoteuse GD::Thumbnail;
   my $thumb = GD::Thumbnail->new;
   my $raw   = $thumb->create('test.jpg', 80, 2);
   my $mime  = $thumb->mime;
   warn sprintf "Dimension: %sx%s\n", $thumb->width, $thumb->height;
   open    IMG, ">thumb.$mime" or die "Error: $!";
   binmode IMG;
   print   IMG $raw;
   close   IMG;

Quotemy $raw = $thumb->create($image    , $max, $info);
   my $raw = $thumb->create('test.jpg',   80, 1    );


Is there a file I can put these commands in, such as the index.php, so I can use GD's thumbnail output?

Joachim Müller

Look: as suggested, Coppermine already creates the thumbnails for you. There's no need to add code to dynamically create thumbnails, as this would mean a huge waste of resources to re-create the thumbnail whenever it is needed. If you must have this code, then you'll have to figure this out on your own where exactly to apply it - I'm not going to waste hours to integrate your suggested code into the coppermine core code. Coppermine already has the needed functions as well to create a thumbnail - if you need dynamically-created thumbnails, you can use that function (although it absolutely doesn't make sense at all). Why don't you go ahead and explain why you so badly insist on having that particular piece of code reside in Coppermine. Maybe someone will come up with the needed code changes if you can explain why you need them.

Frink

Quote from: GauGau on August 10, 2007, 07:19:14 AM
Coppermine already has the needed functions as well to create a thumbnail - if you need dynamically-created thumbnails, you can use that function (although it absolutely doesn't make sense at all).

Where is this function located? 

Joachim Müller

Search the core code - as suggested, I'm not going to look into this for you, as it is silly in the first place. You need it -> you code it. Won't answer any more questions, as you failed to do as suggested:
Quote from: GauGau on August 10, 2007, 07:19:14 AMWhy don't you go ahead and explain why you so badly insist on having that particular piece of code reside in Coppermine. Maybe someone will come up with the needed code changes if you can explain why you need them.
I'm not going to waste my time for to explain how coppermine works. If you're a skilled coder, you can find out easily. If you're not a coder, you won't be able to accomplish the hack you're after.

Frink

Quote from: GauGau on August 10, 2007, 10:35:19 AMWon't answer any more questions, as you failed to do as suggested:
Why don't you go ahead and explain why you so badly insist on having that particular piece of code reside in Coppermine. Maybe someone will come up with the needed code changes if you can explain why you need them.


Well I want to be able to adjust the different ways thumbnails are exported.  (Such as altering the ways generating thumbnails are made) 


I want to overlay image info, such as the size of the raw image, on the thumbnail.

Joachim Müller

Quote from: Frink on August 10, 2007, 10:49:42 AMWell I want to be able to adjust the different ways thumbnails are exported.  (Such as altering the ways generating thumbnails are made)
I don't understand. Please re-phrase.


Quote from: Frink on August 10, 2007, 10:49:42 AMI want to overlay image info, such as the size of the raw image, on the thumbnail.
This is called "watermarking" and has been covered in many threads/mods already.

Nibbler

The code you posted is perl; you can't use perl in Coppermine as it is a php app. If you want to modify the image creation code look at resize_image() in include/picmgmt.inc.php

Frink

Quote from: Nibbler on August 10, 2007, 06:04:41 PM
The code you posted is perl; you can't use perl in Coppermine as it is a php app. If you want to modify the image creation code look at resize_image() in include/picmgmt.inc.php


Thanks Nibbler. 

I found a script which has what I want that uses GD.  But I have no clue where to put it.

Here is what it looks like...

<?php

    $i 
= new imagethumbnail_info();
    
$i->open("butterfly.jpg");
    
$i->setX(200);
    
$i->info();
    
    
header("Content-type: image/jpeg;");
    
$i->imagejpeg();

    class 
imagethumbnail {
    
        var 
$filename;
        var 
$x;
        var 
$y;
        var 
$image;
        var 
$thumbnail;

        function 
imagethumbnail() {

        }
        
        function 
open($filename) {

            
$this->filename $filename;
            
$imageinfo = array();
            
$imageinfo getimagesize($this->filename,$imageinfo);
            
            
$this->old_x $imageinfo[0];
            
$this->old_y $imageinfo[1];
                        
            switch (
$imageinfo[2]) {
                case 
"1"$this->image imagecreatefromgif($this->filename); break;
                case 
"2"$this->image imagecreatefromjpeg($this->filename); break;
                case 
"3"$this->image imagecreatefrompng($this->filename); break;
            }
            
        }

        function 
setX($x="") {
            if (isset(
$x)) { $this->$x; }
            return 
$this->x;
        }

        function 
setY($y="") {
            if (isset(
$y)) { $this->$y; }
            return 
$this->y;
        }

        function 
generate() {

            if (
$this->and $this->0) {
                
$new_x $this->x;
                
$new_y $this->y;
            } elseif (
$this->and $this->!= "") {
                
$new_x $this->x;
                
$new_y = ($this->x/$this->old_x)*$this->old_y;
            } else {
                
$new_x = ($this->y/$this->old_y)*$this->old_x;
                
$new_y $this->y;
            }

            
$this->thumbnail imagecreatetruecolor($new_x,$new_y);
            
$white imagecolorallocate($this->thumbnail,255,255,255);
            
imagefill($this->thumbnail,0,0,$white);

            
imagecopyresampled $this->thumbnail$this->image0000$new_x$new_y$this->old_x$this->old_y);

        }

        function 
imagegif($filename="") {
            if (!isset(
$this->thumbnail)) { $this->generate(); }
            
imagetruecolortopalette($this->thumbnail,0,256);
            if (
$filename=="") {
                
imagegif($this->thumbnail);
            } else {
                
imagegif($this->thumbnail,$filename);
            }
        }

        function 
imagejpeg($filename="",$quality=80) {
            if (!isset(
$this->thumbnail)) { $this->generate(); }
            
imagejpeg($this->thumbnail,$filename,$quality);
        }

        function 
imagepng($filename="") {
            if (!isset(
$this->thumbnail)) { $this->generate(); }
            if (
$filename=="") {
                
imagepng($this->thumbnail);
            } else {
                
imagepng($this->thumbnail,$filename);
            }
        }

    }

    class 
imagethumbnail_info extends imagethumbnail {

        var 
$info;
        var 
$color;

        function 
imagethumbnail_info() {
            
$this->info "";
            
$this->color "FFFFFF";
        }
        
        function 
setColor($color="") {
            if (isset(
$color)) { $this->color $color; }
            return 
$this->color;
        }

        function 
info() {

            if (!isset(
$this->thumbnail)) { $this->generate(); }
            
            
$i_x imagesx($this->thumbnail);
            
$i_y imagesy($this->thumbnail);

            
$image imagecreatetruecolor($i_x,($i_y+30));
            
$black imagecolorallocate($image,0,0,0);
            
$white imagecolorallocate($image,255,255,255);
            
imagefill($image,0,0,$black);
            
imagecopy($image,$this->thumbnail,0,0,0,0,$i_x,$i_y);
            
            
$stringlength strlen($this->old_x." by ".$this->old_y)*imagefontwidth(4);
            
            
imagestring($image,4,($i_x-$stringlength)/2,$i_y+5,$this->old_x." by ".$this->old_y,$white);
            
            
imagedestroy($this->thumbnail);

            
$this->thumbnail $image;

        }

    }
    
?>


Here is where I got the script from http://www.phpgd.com/scripts.php?script=38.

If anyone one the board can help me, it will be greatly appreciated.

Joachim Müller

As suggested various times on this thread, your request is invalid in the first place, since coppermine already comes with GD support, so there's no use in re-requesting it. Your customization requests are beyond what you can expect from regular free support, so you're on your own with this: code it by yourself or hire someone to code it for you. Please do not try to draw attention to your request that has been labelled "invalid" for good reasons by bumping it constantly to the top with code snippets taken from some place. Coming up with working code doesn't just mean copying bits of code from all over the internet and just pasting it into the corresponding sections in Coppermine. What you're up to requires in-depth understanding of coppermine, good coding skills and a lot of time to come up with the code and test it.
Additionally, you haven't done as suggested
Quote from: GauGau on August 10, 2007, 03:55:52 PM
I don't understand. Please re-phrase.
, so I'm reluctant to see this discussion continue.