Skip to content

Commit

Permalink
Added quality options
Browse files Browse the repository at this point in the history
  • Loading branch information
descovi authored Nov 18, 2016
1 parent 8924a37 commit c35ecdb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/jekyll/srcset/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ def optimize?(site)
def cache_dir(site)
config(site)['cache']
end

def jpeg_quality(site)
if config(site).key? 'jpeg_quality'
config(site)['jpeg_quality']
else
80 #DEFAULT QUALITY
end
end


def generate_image(site, src, attrs)
cache = cache_dir(site)
Expand Down Expand Up @@ -97,8 +106,9 @@ def generate_image(site, src, attrs)
img.scale!(scale) if scale <= 1
img.strip!

if dest.match(/\.jpg$/)
img.write(dest){ self.quality = 80 }
if dest.match(/\.jpg$/) or dest.match(/\.jpeg$/)
quality = jpeg_quality(site)
img.write(dest) do self.quality = quality end
else
img.write(dest)
end
Expand Down

0 comments on commit c35ecdb

Please sign in to comment.