Forums / Install & configuration / Images with gd

Images with gd

Author Message

Douglas Hammond

Wednesday 04 June 2003 9:07:14 pm

I'm trying to get it to work and there have been no clear way to do it so i am trying to show my progress here.

make sure in settings/overides/image.ini.append.php you have

<?php /* #?ini charset="iso-8859-1"?

[ConverterSettings]
UseConvert=false
UseGD=true

[Rules]
DefaultRule=image/jpeg;gd
Rules[]=image/jpeg;image/jpeg;gd
Rules[]=image/png;image/png;gd
Rules[]=image/gif;image/png;gd
Rules[]=image/xpm;image/png;gd

*/ ?>

****NOTICE THE RULES**** These rules tell what to use for conversion. Usualy "convert" wiche uses imagemagick or "gd" to use libgd to do the conversion. Gif support may not be included in your php or not.

After i do this i seem to be having problems still, it looks like there is a trailing '/' before a the origional file name.

my next venture will be to find where this is added.

any suggestions would be great.

Huib Kleinhout

Wednesday 04 June 2003 9:23:37 pm

What problems do you have?
No images at all or error/warnings?

Douglas Hammond

Thursday 05 June 2003 8:05:18 am

I have just reinstalled ez3(not 3.1beta)

turned on debugging and here is my image.ini.append.php

<?php /* #?ini charset="iso-8859-1"?

[ConverterSettings]
UseConvert=false
UseGD=true

[Rules]
DefaultRule=image/jpeg;gd
Rules[]=image/jpeg;image/jpeg;gd
Rules[]=image/png;image/png;gd
Rules[]=image/gif;image/png;gd
Rules[]=image/xpm;image/png;gd

*/ ?>

here is what i get from debugging

eZ debug
Warning: PHP Jun 05 2003 11:03:33
Undefined variable: wwwDir in /home/ez/public_html/lib/ezutils/classes/ezsys.php on line 539
Timing: Jun 05 2003 11:03:33
Script start
Timing: Jun 05 2003 11:03:33
Module start 'content'
Warning: eZModuleOperationInfo::execute Jun 05 2003 11:03:33
Missing main operation memento for key: 9676311a120b17860aa9a2309ab2d865
Warning: PHP Jun 05 2003 11:03:33
imagecreatefromjpeg(var/storage/reference/image//phpkUgijP.jpg): failed to open stream: No such file or directory in /home/ez/public_html/lib/ezimage/classes/ezimagegd.php on line 165
Warning: PHP Jun 05 2003 11:03:33
Undefined offset: 1 in /home/ez/public_html/lib/ezimage/classes/ezimagemanager.php on line 410
Warning: PHP Jun 05 2003 11:03:33
Undefined offset: 1 in /home/ez/public_html/kernel/classes/datatypes/ezimage/ezimagevariation.php on line 209
Warning: PHP Jun 05 2003 11:03:33
getimagesize(): Read error! in /home/ez/public_html/kernel/classes/datatypes/ezimage/ezimagevariation.php on line 211
Warning: PHP Jun 05 2003 11:03:33
Undefined offset: 1 in /home/ez/public_html/kernel/classes/datatypes/ezimage/ezimagevariation.php on line 216
Warning: PHP Jun 05 2003 11:03:33
Undefined offset: 1 in /home/ez/public_html/kernel/classes/datatypes/ezimage/ezimagevariation.php on line 223
Error: eZImageVariation Jun 05 2003 11:03:33
Undefined attribute 'contentobject_attribute_id, version, requestedwidth, requestedheight', cannot get
Error: eZImageVariation Jun 05 2003 11:03:33
Undefined attribute 'contentobject_attribute_id, version, requestedwidth, requestedheight', cannot get
Timing: Jun 05 2003 11:03:33
Module end 'content'
Timing: Jun 05 2003 11:03:33
End

notice Warning: PHP Jun 05 2003 11:03:33
imagecreatefromjpeg(var/storage/reference/image//phpkUgijP.jpg):
there is a double '/' before the file name.

in the past i have edited the souce and removed the extra '/' but then i get that it can't open the file in var/storage/refrence/image. Shouldn't it be looking in var/storage/origional/image. If not were where does a copy get made from var/storage/origional/image to var/storage/refrence/image?

Huib Kleinhout

Thursday 05 June 2003 10:54:53 am

a quick look:
I think somethings wrong with the wwwdir var in ezsys.php. It is read from php server variables (see source of ezsys.php) but in your case empty.
This why the reference dir is var/storage/reference/image/ instead of /home/ez/public_html/var/storage/reference/image/

Are you using some kind of uncommon server/configuration?

Douglas Hammond

Thursday 05 June 2003 11:21:30 am

wwwDir is not a problem, my site is a virtual host and using relative pathes is ok.

the problem I see is where it adds an extra slash to the file name and var/storage/reference.

Why is it looking in reference dir instead of origional dir? When is the image created or copied to the reference dir? i can't find it.

Huib Kleinhout

Thursday 05 June 2003 10:30:56 pm

EZ creates a reference image first, from that reference image other variations are converted.
Something goes wrong when creating the reference image, because it does not seem to exist. Though I don't think the extra slash would be the problem

> When is the image created or copied to the reference dir? i can't find it.
It starts in kernel/classes/datatypes/ezimage/ezimagevariation.php

Douglas Hammond

Friday 06 June 2003 8:48:22 am

I can't find where a copie is put in the reference dir.

I have lookin in image variation and all i can find is were it is copy from reference dir and a variaitoin is put into the variation dir

Douglas Hammond

Friday 06 June 2003 11:38:16 am

this is from the 3.0-2 code straight off the web site.

i finaly got it work work with gd but i think not it wont work with imagmagick.

see next message

Douglas Hammond

Friday 06 June 2003 11:48:55 am

sorry
fix the $to_dst=$from to $to_dest=$to in imagegd.php

Douglas Hammond

Friday 06 June 2003 1:14:27 pm

More acuratly her is a diff

diff -urN kernel/classes/datatypes/ezimage/ezimagevariation.php /home/ez/public_html/kernel/classes/datatypes/ezimage/ezimagevariation.php
--- kernel/classes/datatypes/ezimage/ezimagevariation.php 2003-04-24 09:08:07.000000000 -0400
+++ /home/ez/public_html/kernel/classes/datatypes/ezimage/ezimagevariation.php 2003-06-06 15:45:53.000000000 -0400
@@ -205,23 +205,19 @@
false
);

- $refImageFilename = explode( ':', $refImagename);
- $refImagename = $variationPath . '/' . $additionalPath . '/' . $refImageFilename[ 1 ];
+ $imageFullPath = $variationPath . '/' . $additionalPath . '/'. $refImagename;

- $imgsize = getimagesize ( $refImagename );
- unset( $refImagename );
+ $imgsize = getimagesize ( $imageFullPath );

$imageVariation = new eZImageVariation( array("contentobject_attribute_id" => $ezimageobj->attribute( "contentobject_attribute_id" ),
"version" => $ezimageobj->attribute( "version" ),
- "filename" => $refImageFilename[1],
+ "filename" => $refImagename,
"additional_path" => $additionalPath,
"requested_width" => $rwidth,
"requested_height" => $rheight,
"width" => $imgsize[0],
"height" => $imgsize[1] ) );

- $imageFullPath = $variationPath . '/' . $additionalPath . '/' . $refImageFilename[1];
-

if ( filesize( $imageFullPath ) == 0 || !file_exists( $imageFullPath ) )
{
diff -urN kernel/common/image.php /home/ez/public_html/kernel/common/image.php
--- kernel/common/image.php 2003-04-24 09:08:12.000000000 -0400
+++ /home/ez/public_html/kernel/common/image.php 2003-06-06 15:37:00.000000000 -0400
@@ -91,7 +91,7 @@
if ( $useGD )
{
$img->registerType( 'gd', new eZImageGD( EZ_IMAGE_KEEP_SUFFIX,
- EZ_IMAGE_PREPEND_SUFFIX_TAG ) );
+ EZ_IMAGE_KEEP_SUFFIX ) );
}

// Output types
diff -urN lib/ezimage/classes/ezimagegd.php /home/ez/public_html/lib/ezimage/classes/ezimagegd.php
--- lib/ezimage/classes/ezimagegd.php 2003-04-24 09:08:20.000000000 -0400
+++ /home/ez/public_html/lib/ezimage/classes/ezimagegd.php 2003-06-06 15:38:08.000000000 -0400
@@ -157,7 +157,7 @@
}
$src = "";
$dst = "";
- $to_dst = $from;
+ $to_dst = $to;
$to_dst["suffix"] = $to["suffix"];
$src .= $this->convertFileName( $from, $this->FromType );
$dst .= $this->convertFileName( $to_dst, $this->ToType );
@@ -193,9 +193,9 @@
/*!
Calls convert() with the $filters and $scale param.
*/
- function scale( &$from, &$to, &$to_file, &$filters, $scale )
+ function scale( &$from, &$to, &$to_dir, &$to_file, &$filters, $scale )
{
- $this->convert( $from, $to, $to_file, $filters, $scale );
+ $this->convert( $from, $to, $to_dir, $to_file, $filters, $scale );
}

/// Array of allowed input types mapped to the corresponding function.
diff -urN lib/ezimage/classes/ezimagemanager.php /home/ez/public_html/lib/ezimage/classes/ezimagemanager.php
--- lib/ezimage/classes/ezimagemanager.php 2003-04-24 09:08:21.000000000 -0400
+++ /home/ez/public_html/lib/ezimage/classes/ezimagemanager.php 2003-06-06 15:39:17.000000000 -0400
@@ -328,10 +328,10 @@
$this->addFilterRule( $rules, true );
$suffix = $mime["suffix"];
$dirs = "";
- if ( preg_match( "#(.+/)?(.+)$#", $file, $matches ) )
+ if ( preg_match( "#((.+)/)?(.+)$#", $file, $matches ) )
{
- $dirs = $matches[1];
- $file = $matches[2];
+ $dirs = $matches[2];
+ $file = $matches[3];
}
$base = $file;
if ( preg_match( "/(.+)" . $mime["match"] . "/i", $file, $matches ) )
@@ -348,10 +348,10 @@
{
$dest_dirs = "";
$dest_file = $dest;
- if ( preg_match( "#(.+/)?(.+)$#", $dest, $matches ) )
+ if ( preg_match( "#((.+)/)?(.+)$#", $dest, $matches ) )
{
- $dest_dirs = $matches[1];
- $dest_file = $matches[2];
+ $dest_dirs = $matches[2];
+ $dest_file = $matches[3];
}
$dest_base = $dest_file;
if ( preg_match( "/(.+)" . $mime["match"] . "/i", $dest_file, $matches ) )
@@ -410,7 +410,7 @@
list( $mimeType, $storedFileName ) = split(":", $to_file );
eZLog::writeStorageLog( $storedFileName, $dest_dirs );

- return $from_array["dir"] . "/" . $out_file;
+ return $out_file;
}

/*!

Dirk Billerbeck

Wednesday 11 June 2003 2:30:28 pm

Hello Douglas,

I'm sorry, but I'm relative new to Linux and haven't much experience with diff/patch. How can I make use of your diff listing?

TIA.

Regards,

Dirk

Douglas Hammond

Wednesday 11 June 2003 2:58:08 pm

copy the above diff into a file eg. ezimage.diff

move that file into your ezpublish directory

use patch -p5 < ezimage.diff

you may have to change -p5 to -psomeothernumber where someothernumber

-pnum or --strip=num
Strip the smallest prefix containing num leading slashes from each
file name found in the patch file. A sequence of one or more adja-
cent slashes is counted as a single slash. This controls how file
names found in the patch file are treated, in case you keep your
files in a different directory than the person who sent out the
patch. For example, supposing the file name in the patch file was

/u/howard/src/blurfl/blurfl.c

setting -p0 gives the entire file name unmodified, -p1 gives

Douglas Hammond

Wednesday 11 June 2003 3:01:14 pm

Who can i contact re image support?
I would be happy to help fix it up to work with gd.

there are a number of problems that i have stated in these forums but none of them seem to be getting into ezpublisher.

Dirk Billerbeck

Wednesday 11 June 2003 3:42:31 pm

Hi,

ok, I've copied your listing into a file and moved it into my eZ publish directory (/data/apache/ezpublish-3.0-2) and I've tried all possible combinations of -pnum for the patch command but it doesn't work.

With -p0 it seems as if patch would find the correct file but I'm getting the following error message:

patching file kernel/classes/datatypes/ezimage/ezimagevariation.php
patch: **** malformed patch at line 5: false

Do you know what went wrong?

Dirk

Douglas Hammond

Wednesday 11 June 2003 3:57:13 pm

Probly because it looses it's format in this forum.
too bad there is no place for me to upload it here.

if you look at the format close enough you will see that it names a file then tells you where the changes are to be made in that file. A line prefixed by "-" means remove the line and a line prefixed by "+" means add the line.

if you follow it you could do it manualy.

Dirk Billerbeck

Wednesday 11 June 2003 4:01:22 pm

Hmm, I could try it.

Or could you send it to me via email to [email protected]?

TIA.

Regards,

Dirk

Claudius Frank

Thursday 12 June 2003 12:18:50 am

Hi Douglas,

Did you try to publish images too? Or are you able to see the demo images?
To see the images is no problem, neither with GD nor with ImageMagick.
This works without changing proposed by you. but I am not able to publish any image. The errors I posted in the forum "Problems adding pictures with class attribute image"
http://ez.no/developer/ez_publish_3/forum/developer/problems_adding_pictures_with_class_attribute_image

Regards

Douglas Hammond

Thursday 12 June 2003 8:04:39 am

Follow this link to my patch.
http://ez.mojothing.com/

This is the only way I was able to get gd to work for posting images.

The patch fixes

1. trailing slashes in ezimagemanager
2. return only filename not path and filename in ezimagemanager.php(this messes ezimagevariation up as ezimagevariation adds the path again to the results from ezimagemanager)
3. ezimagevariation.php assumes image type is prefixed to the image name witch is no the case when using gd.
4. change image.ini to default to use gd
5. change ezimagegd.php - fix parameters to function scale and changed $to_dst = from to $to_dst=$to(makes a little more sense)
6. changed ezimagedg to scale propartionaly

NOTE:
This will make gd work but may break imagemagick.(Specificaly where ezimage variation makes the assumption the the file name is like jpg:/var/storage/image.jpg the prefixed jpg: is the problem)

Claudius Frank

Tuesday 17 June 2003 5:23:36 am

Hi Douglas,

Thank you very much for your link.
I have downloaded the complete ezpublish_gd from your page and installed it on my shared hosted server. It work very well with demo images and with my own images as well.I hadn't until now enough time to test all the kind of images, e.g. gifs, jpg and so on, but I am sure they will work too.
The work you have done is excellent.

I wonder why the eZ team could not use your work (files). Your Work could answer many questions.

I have an other question!
Did you try to sign up from the demo shop page for example. I tried it and I believe there is the same problem with the link we had with images when we tried to upload them. May be you are able to solve this problem too!

Regards
Claudius