Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (2)
[Sprint/QuietQuail](fix): GIF resize and cropping.
· 988e5b76
Ben
authored
Nov 05, 2019
and
Mark Harding
committed
Nov 05, 2019
988e5b76
Merge branch 'fix/gif-resize' into 'master'
· af77626a
Mark Harding
authored
Nov 05, 2019
[Sprint/QuietQuail](fix): GIF resize and cropping. Closes
#907
See merge request
!386
af77626a
Hide whitespace changes
Inline
Side-by-side
Core/Media/Imagick/Resize.php
View file @
af77626a
...
...
@@ -127,13 +127,38 @@ class Resize
$params
=
$this
->
getResizeParameters
();
// First crop the image
$this
->
image
->
cropImage
(
$params
[
'selectionwidth'
],
$params
[
'selectionheight'
],
$params
[
'xoffset'
],
$params
[
'yoffset'
]);
// If selected with / height differ from selection width/height, then we need to resize
if
(
$params
[
'selectionwidth'
]
!==
$params
[
'newwidth'
]
||
$params
[
'selectionheight'
]
!==
$params
[
'newheight'
])
{
$this
->
image
->
thumbnailImage
(
$params
[
'newwidth'
],
$params
[
'newheight'
]);
// If is animated,
if
(
$this
->
image
->
getNumberImages
()
>
1
)
{
foreach
(
$this
->
image
as
$frame
)
{
// Crop into square.
$frame
->
cropImage
(
$params
[
'selectionwidth'
],
$params
[
'selectionheight'
],
$params
[
'xoffset'
],
$params
[
'yoffset'
]
);
// Resize canvas to new image
$frame
->
setImagePage
(
0
,
0
,
0
,
0
);
// If selected with / height differ from selection width/height, then we need to resize
if
(
$params
[
'selectionwidth'
]
!==
$params
[
'newwidth'
]
||
$params
[
'selectionheight'
]
!==
$params
[
'newheight'
])
{
$frame
->
thumbnailImage
(
$params
[
'newwidth'
],
$params
[
'newheight'
]);
}
}
}
else
{
// Crop the image to selection dimensions
$this
->
image
->
cropImage
(
$params
[
'selectionwidth'
],
$params
[
'selectionheight'
],
$params
[
'xoffset'
],
$params
[
'yoffset'
]
);
// If selected with / height differ from selection width/height, then we need to resize
if
(
$params
[
'selectionwidth'
]
!==
$params
[
'newwidth'
]
||
$params
[
'selectionheight'
]
!==
$params
[
'newheight'
])
{
$this
->
image
->
thumbnailImage
(
$params
[
'newwidth'
],
$params
[
'newheight'
]);
}
}
$this
->
output
=
$this
->
image
;
...
...