Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Possible bug with GD implementation

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1303 Views
  • DesignCity
    Avatar
    38 Posts

    Possible bug with GD implementation Link to this post

    I've been trying to set up some images to display cropped (using CroppedImage) rather than resized (using SetWidth) thumbnails. It seems that no matter what I do, I can't get it to work.

    Something like $image_one.SetWidth(200) works fine, displaying the image resized to 200px wide maximum.

    If I try $image_one.CroppedImage(200,130), I get a wonderful fatal error:

    FATAL ERROR: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions
    At line 47 in /Applications/MAMP/htdocs/ss/sapphire/filesystem/GD.php

    imagecreatetruecolor(0,0)
    line 47 of GD.php

    GD->croppedResize(,)
    line 175 of Image.php

    Image->generateCroppedImage(Object,,)
    line 150 of Image.php

    Image->generateFormattedImage(CroppedImage,,)
    line 125 of Image.php

    Image->getFormattedImage(CroppedImage)
    line of

    call_user_func_array(Array,Array)
    line 145 of Object.php

    ...And so it goes. You get the picture

    It seems that the two sizes aren't getting passed for some reason. If I only try to pass 1 size (eg $image_one.CroppedImage(200)), the error at least recognises that one size has been passed with the second size missing. This seems strange.

    I've tried using the methods described in http://doc.silverstripe.com/doku.php?id=imageupload and still no luck - three hours later... . Anyone have any ideas of what I'm doing wrong, or is this a bug?

    Cheers
    Michael

  • Andy
    Avatar
    230 Posts

    Re: Possible bug with GD implementation Link to this post

    This is a bug in the template system - try:

    [html]
    <% control image_one %>
    $CroppedImage(200,130)
    <% end_control %>
    [/html]

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Possible bug with GD implementation Link to this post

    I believe the template parser can't handle $Property.Subproperty(Parameter). More specifically it's the SSViewer class. If you're feeling lucky you could try implement this.

    It is a little confusing.

    Cheers,
    Sean

  • DesignCity
    Avatar
    38 Posts

    Re: Possible bug with GD implementation Link to this post

    That worked a treat Andy, thanks

    And I'd love to try to implement it, but I'm just a lowly designer still learning PHP... It seems to be similar to learning a foreign language: I can understand most of it, but speaking it is very hard!

    1303 Views
Page: 1
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.