Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Error with GD library?


Go to End


3 Posts   5738 Views

Avatar
Patrick Arlt

Community Member, 15 Posts

3 January 2010 at 9:26pm

Edited: 03/01/2010 9:28pm

I'm having an issue with uploading image in the backend of a silverstripe installation running on MAMP. This looks like an error creating the thumbnail image that is displayed when you pick an image in an ImageField.

As Im running on MAMP, gd should be up and running See Here.

Is this an error with GD? Or am I setting something up wrong on my page the PortfolioItem.php file is available here

Below is the error message that I get. There is an image attached to this post showing where the error occurs.

[Warning] imagecreatefrompng() [function.imagecreatefrompng]: gd-png: fatal libpng error: IDAT: CRC error
GET /portfoliotheme/images/iframe/PortfolioItem/12/PortfolioThumbnail

Line 23 in /Applications/MAMP/htdocs/portfoliotheme/sapphire/filesystem/GD.php
Source

14 // If we're working with image resampling, things could take a while. Bump up the time-limit
15 increase_time_limit_to(300);
16
17 if($filename) {
18 // We use getimagesize instead of extension checking, because sometimes extensions are wrong.
19 list($width, $height, $type, $attr) = getimagesize($filename);
20 switch($type) {
21 case 1: if(function_exists('imagecreatefromgif')) $this->setGD(imagecreatefromgif($filename)); break;
22 case 2: if(function_exists('imagecreatefromjpeg')) $this->setGD(imagecreatefromjpeg($filename)); break;
23 case 3: if(function_exists('imagecreatefrompng')) $this->setGD(imagecreatefrompng($filename)); break;
24 }
25 }
26
27 $this->quality = self::$default_quality;
28 parent::__construct();
29 }

Trace

* imagecreatefrompng(../assets/Uploads/thumb4.png)
Line 23 of GD.php
* GD->__construct(../assets/Uploads/thumb4.png)
Line 297 of Image.php
* Image->generateFormattedImage(CMSThumbnail,,)
Line 264 of Image.php
* Image->getFormattedImage(CMSThumbnail)
Line 211 of Image.php
* Image->CMSThumbnail()
* call_user_func_array(Array,Array)
Line 408 of ViewableData.php
* ViewableData->XML_val(CMSThumbnail,,1)
Line 56 of .cache.Applications.MAMP.htdocs.portfoliotheme.sapphire.templates.Image_iframe.ss
* include(/private/var/folders/fX/fXEdSNLgECSQjs1HvnuQik+++TI/-Tmp-/silverstripe-cache-Applications-MAMP-htdocs-portfoliotheme/.cache.Applications.MAMP.htdocs.portfoliotheme.sapphire.templates.Image_iframe.ss)
Line 357 of SSViewer.php
* SSViewer->process(ViewableData_Customised)
Line 163 of Controller.php
* Controller->handleAction(HTTPRequest)
Line 129 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 119 of Controller.php
* Controller->handleRequest(HTTPRequest)
Line 277 of Director.php
* Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
* Director::direct(/images/iframe/PortfolioItem/12/PortfolioThumbnail)
Line 118 of main.php

Attached Files
Avatar
tobych

Community Member, 97 Posts

7 January 2010 at 5:07pm

I suggest you try to narrow the problem down by trying some image manipulation directly in PHP code, first using the Image class then with the GD library directly. Try to come up with the smallest amount of stuff (data, code, everything) involved in something that fails.

Toby

Avatar
mattclegg

Community Member, 56 Posts

22 April 2010 at 9:57pm

Edited: 22/04/2010 9:57pm

Check your permission of assets folder.

This fixed my similar issue, although Iv had lots of other permission trouble with WAMP/XAMP over permissions and couldn't direct you where to change it in MAMP.

Presuming your running a localhost version; I think there is a feature in 2.4 to 'detect new files' maybe you could get round uploading files by using that?