gd-png error: compression level must be 0 through 9 ^^ #97

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
6 participants
@Ethno-urban

line 1048 to 1052 fix the error log 2013-02-17 14:02:22 Warning: Warning (2): imagepng() [function.imagepng]: gd-png error: compression level must be 0 through 9 in

Update Model/Behavior/UploadBehavior.php
line 1048 to 1052 fix the error log 2013-02-17 14:02:22 Warning: Warning (2): imagepng() [<a href='http://php.net/function.imagepng'>function.imagepng</a>]: gd-png error: compression level must be 0 through 9 in
@davidyell

This comment has been minimized.

Show comment Hide comment
@davidyell

davidyell Feb 19, 2013

Member

@Ethno-urban The quality should be pulled from the config and not hard coded. There is $this->thunbnailQuality which should be configured with this value by the user.

I also ran into this problem and solved it by swapping to imagick.

Member

davidyell commented Feb 19, 2013

@Ethno-urban The quality should be pulled from the config and not hard coded. There is $this->thunbnailQuality which should be configured with this value by the user.

I also ran into this problem and solved it by swapping to imagick.

@josegonzalez

This comment has been minimized.

Show comment Hide comment
@josegonzalez

josegonzalez Feb 19, 2013

Member

Not merging. If you do not set a proper configuration option, that is your own fault. @davidyell has the proper solution for this.

Member

josegonzalez commented Feb 19, 2013

Not merging. If you do not set a proper configuration option, that is your own fault. @davidyell has the proper solution for this.

@rahit

This comment has been minimized.

Show comment Hide comment
@rahit

rahit Apr 8, 2013

Having same problem. Tried to set $this->MyModel->thumbnailQuality = 8; in the controller when user try to upload png. But it's not working. Can anybody kindly tell me why..?

rahit commented Apr 8, 2013

Having same problem. Tried to set $this->MyModel->thumbnailQuality = 8; in the controller when user try to upload png. But it's not working. Can anybody kindly tell me why..?

@davidyell

This comment has been minimized.

Show comment Hide comment
@davidyell

davidyell Apr 8, 2013

Member

@rahit You should be configuring the behaviour in the $actsAs property of your model class.

Member

davidyell commented Apr 8, 2013

@rahit You should be configuring the behaviour in the $actsAs property of your model class.

@josegonzalez

This comment has been minimized.

Show comment Hide comment
@josegonzalez

josegonzalez Apr 8, 2013

Member

You can also use:

$this->MyModel->uploadSettings('YOUR_MODEL_FIELD', 'thumbnailQuality', 8);
Member

josegonzalez commented Apr 8, 2013

You can also use:

$this->MyModel->uploadSettings('YOUR_MODEL_FIELD', 'thumbnailQuality', 8);
@lordmodkore

This comment has been minimized.

Show comment Hide comment
@lordmodkore

lordmodkore Apr 17, 2013

I have this Models, Products has many Images and Images belongs to product. Cant seem to upload multiple images to a certain product.

I have this Models, Products has many Images and Images belongs to product. Cant seem to upload multiple images to a certain product.

@josegonzalez

This comment has been minimized.

Show comment Hide comment
@josegonzalez

josegonzalez Apr 17, 2013

Member

@lordmodkore your issue is unrelated to this issue. Please open another issue with all your issue and related code.

Member

josegonzalez commented Apr 17, 2013

@lordmodkore your issue is unrelated to this issue. Please open another issue with all your issue and related code.

@joshuapaling

This comment has been minimized.

Show comment Hide comment
@joshuapaling

joshuapaling May 1, 2013

Contributor

There is a legitimate issue here, even though the wrong code was submitted for merging. In the doco for this plugin, it says:

"thumbnailQuality: Quality of thumbnails that will be generated, on a scale of 0-100. Not supported gif images when using GD for image manipulation."

In the case of uploading a PNG with 'thumbnailMethod' => 'php', then the thumbnailQuality MUST be between 0-9; and 0 represents the highest quality, not the lowest. So, I set it to 0, which works fine for PNGs. But then you try to upload a JPG for that field, and the 0 setting means you have a horrible, zero-quality JPG. So the same value is used in non-compatible contexts.

In terms of solutions, the obvious ones would be:
a) in the case where it has to be 0-9, convert the provided 0-100 value of thumbnailQuality to a corresponding 0-9 value (eg, 100 would become 0, 40 would become 5, 0 would become 9, etc)
b) create a separate parameter like 'thumbnailQualityForPngsWithPhp' (but better named!)

What do you think, @josegonzalez? I think a) is probably a better solution, but both should be pretty easy to implement - I'd be happy to write the code if you're open to accepting a pull request on this?

Contributor

joshuapaling commented May 1, 2013

There is a legitimate issue here, even though the wrong code was submitted for merging. In the doco for this plugin, it says:

"thumbnailQuality: Quality of thumbnails that will be generated, on a scale of 0-100. Not supported gif images when using GD for image manipulation."

In the case of uploading a PNG with 'thumbnailMethod' => 'php', then the thumbnailQuality MUST be between 0-9; and 0 represents the highest quality, not the lowest. So, I set it to 0, which works fine for PNGs. But then you try to upload a JPG for that field, and the 0 setting means you have a horrible, zero-quality JPG. So the same value is used in non-compatible contexts.

In terms of solutions, the obvious ones would be:
a) in the case where it has to be 0-9, convert the provided 0-100 value of thumbnailQuality to a corresponding 0-9 value (eg, 100 would become 0, 40 would become 5, 0 would become 9, etc)
b) create a separate parameter like 'thumbnailQualityForPngsWithPhp' (but better named!)

What do you think, @josegonzalez? I think a) is probably a better solution, but both should be pretty easy to implement - I'd be happy to write the code if you're open to accepting a pull request on this?

@josegonzalez

This comment has been minimized.

Show comment Hide comment
@josegonzalez

josegonzalez May 1, 2013

Member

I like it. Write me a pull request.

Member

josegonzalez commented May 1, 2013

I like it. Write me a pull request.

josegonzalez added a commit that referenced this pull request Jun 1, 2013

Merge pull request #115 from joshuapaling/master
Fixes issue #97 - invalid param for imagepng()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment