Bug #19045
Cropscale incorrectly crops GIF files
| Status: | Under Review | Start date: | 2008-07-02 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Benjamin Mack | % Done: | 0% |
|
| Category: | - | |||
| Target version: | - | |||
| TYPO3 Version: | 4.2 | Complexity: | ||
| PHP Version: | 5.2 | |||
| Votes: | 0 |
Description
If using cropscale on an imgResource object with a GIF input file whose width is larger than its height eg. 120x80px and cropping to a box eg. 100x100px it will be correctly scaled up to 150x100px and the image area is cropped to 100x100px, but the output file is padded with empty pixels to 150px width, instead of the expected 100px.
PNG and JPG input files are unaffected.
TypoScript/PHP used:
$ts['img'] = 'IMAGE';
$ts['img.']['file'] = $imgFullPath;
$ts['img.']['file.']['format'] = 'jpg';
$ts['img.']['file.']['quality'] = 90;
$ts['img.']['file.']['width'] = '107c'; // This is currently buggy with GIF files (as of T3 4.2.1)
$ts['img.']['file.']['height'] = '107c';
// render thumbnail
$thumbnailImg = $this->cObj->IMAGE;
Typo3 config:
[GFX][gdlib] = 1
[GFX][gdlib_png] = 1
[GFX][im] = 1
[GFX][im_version_5] = im6
[GFX][im_v5effects] = -1
[GFX][im_noScaleUp] = 0
[GFX][png_truecolor] = 1
ImageMagick-6.4.1-8 Macport
PHP 5.2.5 using bundled gdlib (2.0.34 compatible)
Sample attached.
(issue imported from #M8878)
Related issues
| related to Core - Bug #18566: Image crop does not work in RC1 | Closed | 2008-04-05 | ||
| related to Core - Bug #18986: Cropping gif images | Closed | 2008-06-19 |
History
Updated by Johannes Beranek about 4 years ago
t3lib/class.t3lib_stdgraphic.php
line 2181 (in version 4.2.6 that is)
adapt line to
$params .= ' -crop '.$data['origW'].'x'.$data['origH'].'+'.$offsetX.'+'.$offsetY.'! ';
I just added the "!" at the end and it now works - "!" after the crop command tells imagemagick to adjust canvas and viewport.
Didn't test this with any other installations than the one I'm working on right now (4.2.6 with IM 6.3.7), so somebody should probably do this before this fix is commited into core.
Cheers
Updated by Uwe Michelfelder about 4 years ago
I can confirm this.
The fix added here
http://bugs.typo3.org/view.php?id=8025
breaks the correct cropping of GIF-Images in some cases.
Re-adding the ! after the crop command like described above, fixed the problem for me too.
Typo3: 4.2.3
PHP: 5.2.8
ImageMagick: 6.4.4
Updated by Felix Buenemann over 3 years ago
Hmm, this has been submitted over a year ago, I wonder if it's ever going to get fixed ...
Updated by Wolfgang Klinger over 3 years ago
That unfortunately doesn't fix it for me using ImageMagick 6.0.7
Updated by Benjamin Mack about 3 years ago
Felix,
basically your suggestion is a reverse to 8025, do I see this right? Can we narrow the issue down when this happens / or not?
Updated by Felix Buenemann almost 3 years ago
This will have to be specialcased for imagemagick version, because the behaviour of im6 is the opposite of im4. Graphicsmagick crops correctly with both syntaxes.
Meaning for im6 we need the ! after -crop dimensions and for 4.2.9 it needs to be ommited.
I did the following tests:
ImageMagick 6.3.7 08/09/09 Q16:
convert -geometry 53x80! -colors 64 -crop 53x53+0+13 old.gif new.gif
Result: 53x80
convert -geometry 53x80! -colors 64 -crop 53x53+0+13! old.gif new.gif
Result: 53x53
ImageMagick 4.2.9 99/09/01:
convert -geometry 53x80! -colors 64 -crop 53x53+0+13 old.gif new.gif
Result: 53x53
convert -geometry 53x80! -colors 64 -crop 53x53+0+13! old.gif new.gif
Result: 53x80
GraphicsMagick 1.1.11 2008-02-23 Q8:
convert -geometry 53x80! -colors 64 -crop 53x53+0+13 old.gif new.gif
Result: 53x53
convert -geometry 53x80! -colors 64 -crop 53x53+0+13! old.gif new.gif
Result: 53x53
Updated by Felix Buenemann almost 3 years ago
Updated by Felix Buenemann almost 3 years ago
Little reminder, please review Benjamin.
I'm currently using this patch on 4.2.12, 4.3.3 and 4.4.0 installations without problems.
Updated by Chris topher almost 3 years ago
Hi Felix,
the normal workflow is that who wrote a patch send it as an RFC to Core List.
There it will get attentnion (other than here).
Check what you should do: http://typo3.org/teams/core/core-mailinglist-rules
Updated by Felix Buenemann almost 3 years ago
Simple testcase:
temp.img = IMAGE
temp.img {
file = fileadmin/test/img300x200.gif
file.width = 147c
file.height = 147c
wrap = <div style="background:#aaa;float:left">|</div><div style="clear:both" />
}
page = PAGE
page {
5 < temp.img
}
I'll attach img300x200.gif, which is a squared gray box on a 300x200 transparent background.
Updated by Felix Buenemann almost 3 years ago
Attached testcase visualization "bug_8878_fix_testcase", please rename to .png, sorrry.
Attached clean patch against svn rev 8197.
Updated by Felix Buenemann almost 3 years ago
Submitted for review.
Updated by Stefan Galinski over 1 year ago
- Target version deleted (
0)
Hi Felix,
Can you please resubmit your patch if this is still valid?
http://wiki.typo3.org/Contribution_Walkthrough_Tutorials.
Updated by Matthias Hogerheijde 9 months ago
This problem seems to be still existent in T3 4.5.19
A GIF picture original of 150px wide by 80px high cropscaled to 80px by 80px results in the 'image' being cropped, but the file has a transparent padding of 35px left and 35px right, resulting in an image of, you guessed it, 150px wide and 80px high.
I've tested using im6 and gm. Both have the same result.
Updated by Michael Stucki 9 months ago
Hi Matthias,
similar to Stefan, I'd like to invite you to try to submit a patch for this bug. As it seems, someone has attempted to create a patch already, however it is old and might need to be updated.
If you need further help, let me know.
- michael
Updated by Felix Buenemann 9 months ago
- File bug_8878_fix_v1b_updated_4_5_19.patch added
Adapted patch to 4.5.19 (only whitespace changes, untested!).
Updated by Felix Buenemann 9 months ago
@Matthias: Try the updated patch on 4.5.19. I haven't tested it due to lack of time, but it should work.
Updated by Simon Schaufelberger 9 months ago
Hi Felix, please make a patch with git and push it to gerrit.
Updated by Felix Buenemann 9 months ago
@Simon: done: http://review.typo3.org/13996
Updated by Gerrit Code Review 9 months ago
- Status changed from Needs Feedback to Under Review
Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13996
Updated by Matthias Hogerheijde 9 months ago
@Felix I will try to test it this week. Thanks for the quick reply! :)
Obviously I will report back when i've tested the patch.
Updated by Gerrit Code Review 9 months ago
Patch set 1 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/14132
Updated by Gerrit Code Review 29 days ago
Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/13996