Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Issue forks
imageapi_optimize-3226168
Commits
bf820d20
Commit
bf820d20
authored
May 10, 2010
by
Hai-Nam Nguyen
Browse files
Fixed serious bug that made JPG optimization useless
parent
cf1d0cf8
Changes
1
Hide whitespace changes
Inline
Side-by-side
imageapi_optimize.module
View file @
bf820d20
...
...
@@ -158,7 +158,7 @@ function _imageapi_optimize_check_path($path) {
* Optimize image with external commands
*/
function
_imageapi_optimize_optimize
(
$image
,
$dst
)
{
switch
(
$image
->
info
[
'mime
/
type'
])
{
switch
(
$image
->
info
[
'mime
_
type'
])
{
case
'image/png'
:
if
(
$cmd
=
variable_get
(
'imageapi_optimize_optipng'
,
''
))
{
exec
(
"
$cmd
-o5
$dst
"
);
...
...
@@ -169,13 +169,26 @@ function _imageapi_optimize_optimize($image, $dst) {
case
'image/jpeg'
:
if
(
$cmd
=
variable_get
(
'imageapi_optimize_jpegtran'
,
''
))
{
file_save_data
(
exec
(
"
$cmd
-copy none -optimize
$dst
"
)
,
$dst
);
_imageapi_optimize_
exec
(
"
$cmd
-copy none -optimize
$dst
"
,
$dst
);
}
if
(
$cmd
=
variable_get
(
'imageapi_optimize_jfifremove'
,
''
))
{
file_save_data
(
exec
(
"
$cmd
<
$dst
"
)
,
$dst
);
_imageapi_optimize_
exec
(
"
$cmd
<
$dst
"
,
$dst
);
}
break
;
}
return
TRUE
;
}
/**
* Save result of a command into file
*/
function
_imageapi_optimize_exec
(
$cmd
,
$dst
)
{
ob_start
();
passthru
(
$cmd
);
$output
=
ob_get_contents
();
ob_end_clean
();
file_put_contents
(
$dst
,
$output
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment