Skip to content

Commit

Permalink
add option to create progressive jpeg, close #11
Browse files Browse the repository at this point in the history
  • Loading branch information
llavaud committed Jan 1, 2017
1 parent 09a6be6 commit dd52d92
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/Llavaud/Process/Media/Photo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ sub process {
carp "[$obj->{'final'}->{$_}->{'path'}] Failed to resize, $err";
return 0;
}
if (defined $main::OPTIONS{'format'}{$_}{'progressive'} and
$main::OPTIONS{'format'}{$_}{'progressive'} eq 'true' and
my $err = $image->Set(interlace => 'Plane')) {
carp "[$obj->{'final'}->{$_}->{'path'}] Failed to set interlace, $err";
return 0;
}
my $err;
if (defined $main::OPTIONS{'format'}{$_}{'compress'}) {
$err = $image->Write(filename => $obj->{'final'}->{$_}->{'path'}, quality => $main::OPTIONS{'format'}{$_}{'compress'});
Expand Down
2 changes: 1 addition & 1 deletion lib/Llavaud/Process/Media/Video.pm
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ sub thumbnail {
carp "[$obj->{'final'}->{$_}->{'dir'}$obj->{'final'}->{'name'}.jpg] Failed to strip, $err";
return 0;
}
if (my $err = $image->Write(filename => "$obj->{'final'}->{$_}->{'dir'}$obj->{'final'}->{'name'}.jpg", quality => 90)) {
if (my $err = $image->Write(filename => "$obj->{'final'}->{$_}->{'dir'}$obj->{'final'}->{'name'}.jpg", interlace => 'Plane', quality => 90)) {
carp "[$obj->{'final'}->{$_}->{'dir'}$obj->{'final'}->{'name'}.jpg] Failed to write, $err";
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions process-media
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ sub check_conf {
'compress' => '^(?:100|[1-9]?[0-9])$',
'strip' => '^(?:true|false)$',
'strip_exclude' => '^(?:orientation|gps|,)+$',
'progressive' => '^(?:true|false)$',
'resize' => '^\d+$',
'vcodec' => '^x26[45]$',
'vcodec_params' => '^[\w\:\=]+$',
Expand Down
3 changes: 3 additions & 0 deletions process-media.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ web_photo:
# a low value result in a better compression but in a lower quality
compress: 90

# create a progressive jpeg
progressive: true

# if set to true, all metadata will be removed except ones specified by strip_exclude
strip: true

Expand Down

0 comments on commit dd52d92

Please sign in to comment.