Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » [Warning] imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 12188 Views
  • juandavidgc
    Avatar
    Community Member
    36 Posts

    [Warning] imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions Link to this post

    Hey! good morning everybody!

    I have been installed the image_gallery module, but i have a problem. In the section admin everything is fine, but in the public site, when i try to get into gallery page, i get this error:

    [Warning] imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions
    GET /galerias/?flush=1

    Line 64 in /var/www/vhosts/mysite.com/httpdocs/sapphire/filesystem/GD.php
    Source

    55    /**
    56     * Resize an image to cover the given width/height completely, and crop off any overhanging edges.
    57     */
    58    function croppedResize($width, $height) {
    59       if(!$this->gd) return;
    60       
    61       $width = round($width);
    62       $height = round($height);
    63       
    64       $newGD = imagecreatetruecolor($width, $height);
    65       
    66       // Preserves transparency between images
    67       imagealphablending($newGD, false);
    68       imagesavealpha($newGD, true);
    69       
    70       $destAR = $width / $height;

    Anybody know what is the problem? Thanks!

  • UncleCheese
    Avatar
    4085 Posts

    Re: [Warning] imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions Link to this post

    Make sure you have all the dimensions set in your ImageGalleryPage Configuration tab.

  • juandavidgc
    Avatar
    Community Member
    36 Posts

    Re: [Warning] imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions Link to this post

    Perfect!

    That was the solution!

    Thank you so much!

  • vancouverWill
    Avatar
    Community Member
    121 Posts

    Re: [Warning] imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions Link to this post

    I've had this problem, shouldn't this be validated on the form either frontend or backend to make it impossible for people to make mistakes. Lots of silverstripe projects customers have access to CMS so it is definitely a risk that they change the form and then it corrupts on the frontend of the site without them realising what they have done. I thought that I could just set one setting for the thumbnail and the other side would be worked out depeding on what the ratio of the photo size was.

    This should ideally be set as standard, validation so that either neither height or width is set or that both are set.

    Otherwise really great module and really impressed by what you have accomplished.

    Cheers

    Will

  • UncleCheese
    Avatar
    4085 Posts

    Re: [Warning] imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions Link to this post

    I've since patched this bug so that 0 is never an accepted value for image size.

  • sureshk
    Avatar
    Community Member
    10 Posts

    Re: [Warning] imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions Link to this post

    Hi UncleCheese,
    I am getting this strange error for Image:

    [Warning] imagejpeg() [function.imagejpeg]: Unable to open '../assets/Uploads/_resampled/CMSThumbnail-Building-HP-4.jpg' for writing
    GET /images/iframe/HomepageSliderSlide/113/Photo

    Line 397 in /var/www/vhosts/friendsofpubliced.org/httpdocs/sapphire/filesystem/GD.php
    Source

    388             case "gif": $type = 1; break;
    389             case "jpeg": case "jpg": case "jpe": $type = 2; break;
    390             default: $type = 3; break;
    391          }
    392          
    393          // if the extension does not exist, the file will not be created!
    394          
    395          switch($type) {
    396             case 1: imagegif($this->gd, $filename); break;
    397             case 2: imagejpeg($this->gd, $filename, $this->quality); break;

    Can you give me suggesstion how this error is rectified.
    I increased the memory size to 128MB using this code "ini_set('memory_limit', '128M');" in mysite/_config.php file.
    But It is not giving the solution for this error.

    I am not getting this error in my localhost with the same server copy. This error is coming in Production server only.

  • UncleCheese
    Avatar
    4085 Posts

    Re: [Warning] imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions Link to this post

    Can you give me some context? Is this the ImageGallery module? What are you trying to do?

  • sureshk
    Avatar
    Community Member
    10 Posts

    Re: [Warning] imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions Link to this post

    It is coming in ImageGallery module, for "cover Image " under Albums tab.
    This same error also coming in another Page used for Homepage slide shows .
    class HomepageSlider extends Page {
       static $defaults = array(
          'HideInSitemap' => '1',
          'ShowInMenus' =>'0',
       );
       
       static $allowed_children = array(
          'HomepageSliderSlide'
       );

    and

    class HomepageSliderSlide extends Page {
       static $defaults = array(
          'HideInSitemap' => '1',
          'ShowInMenus' =>'0',
       );
       
       static $db = array();
       
       static $has_one = array(
          'Photo' => 'Image'
       );

    12188 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.