GImage: division by zero under some circumstances

Creating and modifying plugins.
Post Reply
bbruecker
Regular
Posts: 19
Joined: Tue Sep 20, 2005 2:51 pm
Location: Berlin
Contact:

GImage: division by zero under some circumstances

Post by bbruecker »

Hi,

I've got a problem with the GImage-Plugin:

I want to use following syntax to display an image in a proper size:

Code: Select all

[GImage size=sized]Rennrad/DSCN1439.JPG[/GImage]
The picture is displayed correctly with the expected size, but you will find on the bottom of the page those two lines:

Code: Select all

Warning: Division by zero in /kunden/benjaminbruecker.de/webseiten/s9y/plugins/serendipity_event_galleryimage/serendipity_event_galleryimage.php on line 219
Warning: Division by zero in /kunden/benjaminbruecker.de/webseiten/s9y/plugins/serendipity_event_galleryimage/serendipity_event_galleryimage.php on line 227
There are no errors with “size=full” or if I don’t use any size-descriptors. And a more comlex syntax like this:

Code: Select all

[GImage link=album; target=new]Rennrad/DSCN1439.JPG[/GImage]
is working fine too.

Any idea about how to fix the “sized” problem?
TX, Benjamin
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: GImage: division by zero under some circumstances

Post by garvinhicking »

It seems you are using an older version of the plugin. My line 219 contains:

Code: Select all

			} elseif ($newheight > $maxheight) {
And there such an error cannot happen.

For some debugging, modify your plugin file and change this:

Code: Select all

	function g2_imagesize($width, $height, $maxsize) {
		$maxwidth = $maxsize;
		$maxheight= $maxsize;
to this

Code: Select all

	function g2_imagesize($width, $height, $maxsize) {
		$maxwidth = $maxsize;
		$maxheight= $maxsize;
                echo "Width: $width, Height: $height, Maxsize: $maxsize<br />\n";
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bbruecker
Regular
Posts: 19
Joined: Tue Sep 20, 2005 2:51 pm
Location: Berlin
Contact:

Post by bbruecker »

Hi Garvin,

I found this in the header of the file:

Code: Select all

// Changes from dma147: v1.4 26 Sept 2005:
// fixed some minor bugs 
I checked spartacus bevore, but I'm sure it didn't displayed that there is a newer version. What should be the most recent version?

After I changed the lines, I got the following error

Code: Select all

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /kunden/benjaminbruecker.de/webseiten/s9y/plugins/serendipity_event_galleryimage/serendipity_event_galleryimage.php on line 630
when I load any page from the blog.

Oh s..., after I replaced new with the old lines the error continues, I must hit some key anywhere..., and I didn't backed up the S9Y files, bevore experimenting with code. ARGGGG!

So, I'm realy in trouble. Where can I get the most recent gallery image plugin file without using spartacus?

Benjamin
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

You can get it here: http://cvs.sourceforge.net/viewcvs.py/* ... rev=1.9999

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bbruecker
Regular
Posts: 19
Joined: Tue Sep 20, 2005 2:51 pm
Location: Berlin
Contact:

Post by bbruecker »

Hi,

I fixed the installation. The failure must be a side effect of Dreamweaver or Windows or what the hell, because when I inserted the text via copy and paste, and uploaded the file, the parse error remains, so the parse error is an error orginated by uploading the dreamweaver edited file. Strange

When I saved the file with firefox and then uploaded the file via filezilla I could use my serendipity, but there also remains some fialurs in the head of each page. So I decided to uninstall the plugin, delete the pluginfolder and reinstaled it again via spartacus. That worked.

Now there are only two other parse errors:

Code: Select all

Warning: Division by zero in /kunden/benjaminbruecker.de/webseiten/s9y/plugins/serendipity_event_galleryimage/serendipity_event_galleryimage.php on line 203
Warning: Division by zero in /kunden/benjaminbruecker.de/webseiten/s9y/plugins/serendipity_event_galleryimage/serendipity_event_galleryimage.php on line 211
You can check this out here: http://s9y.benjaminbruecker.de/archives ... nnrad.html

I installed the plugin via spartacus today, so it is the most fresh file. G2 is also updated.

What's wrong?

Regards,
Benjamin

BTW: I always stoumble by configurating the plugin at this point "Absolute album-path" is wrong, I have to put the g2data-Path. This is the path under /albums/. Can somebody correct this missleading description please?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

I need you to use the patch I mentioned above. I cannot help you without the output given by the patch.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bbruecker
Regular
Posts: 19
Joined: Tue Sep 20, 2005 2:51 pm
Location: Berlin
Contact:

Post by bbruecker »

Hi Garvin,

I was a little afraid of changing the text. I tryed again to change the text with dreamweaver, and the result was the same: The whole s9y-site crashed. This time had make a backup, but this takes a little time to keep it running.

With screem at linux it worked. Here is the result (but isn't it the same like division by zero) ?

Code: Select all

Width: , Height: , Maxsize: 640

Warning: Division by zero in /kunden/benjaminbruecker.de/webseiten/s9y/plugins/serendipity_event_galleryimage/serendipity_event_galleryimage.php on line 203

Warning: Division by zero in /kunden/benjaminbruecker.de/webseiten/s9y/plugins/serendipity_event_galleryimage/serendipity_event_galleryimage.php on line 211
I hoped that helps you helping.
Regards,
Benjamin
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

It seems that the original image size could not be fetched.

In line 574 you can find this code:

Code: Select all

			$thissize = getimagesize($album_base.'/'.$album.'/'.$photo.".".$photo_ext);
			if (strtolower($param_array['size']) == 'sized') {
				$newsize = $this->g2_imagesize($thissize[0], $thissize[1], $this->get_config('popup_max'));
				$width= $newsize[0];
				$height = $newsize[1];
				$attr = 'width="'.$width.'" height="'.$height.'"';
			} elseif (strtolower($param_array['size']) == 'thumb') {
				$newsize = $this->g2_imagesize($thissize[0], $thissize[1], $this->get_config('thumb_max'));
				$width= $newsize[0];
				$height = $newsize[1];
				$attr = 'width="'.$width.'" height="'.$height.'"';
			} else {
				list($width, $height, $type, $attr) = getimagesize($album_abs."/albums/".$album."/".$photo.".".$photo_ext);
			}
Change the first line of it to this:

Code: Select all

$thissize = getimagesize($album_abs.'/albums/'.$album.'/'.$photo.".".$photo_ext);
Maybe this gets the right image size then.

And don't use dreamweaver for this! Dreamweaver does not preserve original file contents.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bbruecker
Regular
Posts: 19
Joined: Tue Sep 20, 2005 2:51 pm
Location: Berlin
Contact:

Post by bbruecker »

Great,

that's it! Thank you Garvin.

I will never use Dreamweaver for s9y again. I've learnd it on the hard trail.

What editor would you suggest? God, old Notepad.exe at windows? It is limeted by the filesize. Write.exe seems to me to dangerous too.

Regard's
Benjamin
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

You could use WordPad. But I suggest using a real editor, there are thousands of them out there.

Weaverslave, ultraedit, notepad++, editplus, ...

I'll commit the fix then to the plugin,
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Real programmers use Vim or XEmacs. Fakers use TextPad.

Master programmers use ed. :D
Judebert
---
Website | Wishlist | PayPal
Post Reply