Hi there,
I'm attempting to generate cache of all our thumbnails for all our images. The reason why I want to do this is because we have a php script that pulls a random set of thumbnails from the database and combines them into a single JPEG image that is then displayed in our email signature (the email signature calls the php script which returns the image). As far as I understand it, the script tries to get the URL of the cached thumbnails, and generates the combined image from the URLs given to it from ZenPhoto. Unfortunately, since upgrading to 1.4.3, this no longer works.
The script is below;
<br />
<?php</p>
<p>if (!defined('ZENFOLDER')) { define('ZENFOLDER', 'zp-core'); }</p>
<p>define('OFFSET_PATH', 0);<br />
require_once(ZENFOLDER . "/template-functions.php");</p>
<p>$g = isset($_GET['g'])?$_GET['g']:"retouching";<br />
$n = isset($_GET['n'])?$_GET['n']:8;<br />
$c = 0;</p>
<p>$im = imagecreatetruecolor(($n*75)-4,71);<br />
$fill= imagecolorallocate($im,255,255,255);<br />
imagefill($im,0,0,$fill);</p>
<p>$_zp_current_album = new Album($_zp_gallery,$g);<br />
$subalbums = $_zp_current_album->getAlbums();</p>
<p>if(isset($_GET['r']))<br />
{<br />
$keys = array_rand($subalbums, $n);<br />
} else<br />
{<br />
while ($c < $n)<br />
{<br />
$keys[$c] = $c;<br />
$c ++;<br />
};<br />
};</p>
<p>$c = 0;</p>
<p>foreach ($keys as $key){<br />
$subalbumObj = new Album($_zp_gallery,$subalbums[$key]);<br />
$tn = imagecreatefromjpeg(".".urldecode($subalbumObj->getAlbumThumb()));<br />
imagecopy($im, $tn,($c*75), 0, 0, 0, 71, 71);<br />
$c++;<br />
};</p>
<p>header('Content-Type: image/jpeg');<br />
imagejpeg($im, NULL, 100);</p>
<p>?><br />
I'm getting errors in the error_log that suggests that the URL zenphoto returns is trying to create a new thumbnail, rather than using the cached file. So I tried to pre-cache the thumbnails. This seems to work, however when clicking on the little thumbnail icon in overview-Cache page, it gives me the Debug i.php page for the thumbnail, and the image link is broken. If I look at the link to the image, it is;
Maybe that doesn't matter, I'm not sure if that's really the problem. The error that we get in the error_log from ZenPhoto is;
[31-Jul-2012 11:23:34] PHP Warning: imagecreatefromjpeg(./zp-core/i.php?a=retouching/nokia&i=Nokia-Guitar-RGB-Final_WEB_ZP.jpg&w=71&h=71&c=1&cw=975&ch=975&cx=0&cy=139&q=75&t=1&wmk=!) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home2/username/public_html/signature_strip.php on line 36
[31-Jul-2012 11:23:34] PHP Warning: imagecopy(): supplied argument is not a valid Image resource in /home2/username/public_html/signature_strip.php on line 37
So it seems our signature_strip.php script asks for the URL of the thumbnail, ZenPhoto doesn't think it isn't cached so it returns a URL that generates a new thumbnail, however this is something that our script cannot handle? Is that correct? Or do I not understand it properly? Apologies as I did not write the script and I am not a PHP programmer. I am trying to find the root of the problem so I can either try and fix it myself, or better describe the issue to someone who is better versed in PHP.
Any help with this would be greatly appreciated!
thanks!
Tristan.