Skip to content
This repository was archived by the owner on Nov 23, 2018. It is now read-only.

Commit c6e84a8

Browse files
committed
Reworked image flow fixes most of #169
1 parent d701a01 commit c6e84a8

File tree

2 files changed

+65
-12
lines changed

2 files changed

+65
-12
lines changed

build.xml

+62-10
Original file line numberDiff line numberDiff line change
@@ -974,17 +974,25 @@
974974
<else>
975975
<if>
976976
<!-- Then check for availability if unix -->
977-
<available file="optipng" filepath="${ENV.PATH}"/>
977+
<available file="optipng" filepath="${ENV.PATH}"/>
978978
<var name="optipng.executable" value="optipng"/>
979979
<if>
980980
<equals arg1="${images.optipng.newer}" arg2="true"/>
981981
<var name="optipng.available" value="true"/>
982982
</if>
983+
<else>
984+
<var name="optipng.available.older" value="true"/>
985+
</else>
983986
</if>
987+
<else>
988+
<!-- Print out message if optipng is not available -->
989+
<echo message="*** optipng NOT INSTALLED. SKIPPING OPTIMIZATION OF PNGs." />
990+
<echo message="*** Install optipng to enable png optimization." />
991+
<echo message="*** For instructions see 'Dependencies' at: https://github.com/h5bp/ant-build-script/wiki/Platform" />
992+
</else>
984993
</else>
985994
</if>
986-
987-
<!-- Now check for availability -->
995+
988996
<if>
989997
<equals arg1="${optipng.available}" arg2="true"/>
990998
<then>
@@ -1018,7 +1026,7 @@
10181026
</then>
10191027
</if>
10201028

1021-
<apply executable="${optipng.executable}" dest="./${dir.publish}/${relative.image.dir}/" osfamily="${os.family}">
1029+
<apply executable="${optipng.executable}" dest="./${dir.publish}/${relative.image.dir}/">
10221030
<fileset dir="./${dir.source}/${relative.image.dir}/" includes="**/*.png" excludes="${images.bypass}, ${images.default.bypass}"/>
10231031
<arg value="-quiet"/>
10241032
<arg value="-o7"/>
@@ -1033,11 +1041,55 @@
10331041
</for>
10341042
</then>
10351043
<else>
1036-
<!-- Print out message if optipng is not available -->
1037-
<echo message="*** optipng NOT INSTALLED. SKIPPING OPTIMIZATION OF PNGs." />
1038-
<echo message="*** Install optipng to enable png optimization." />
1039-
<echo message="*** For instructions see 'Dependencies' at: https://github.com/h5bp/ant-build-script/wiki/Platform" />
1044+
<if>
1045+
<equals arg1="optipng.available.older" arg2="true"/>
1046+
<then>
1047+
<!-- work around https://sourceforge.net/tracker/?func=detail&aid=2671422&group_id=151404&atid=780916 -->
1048+
<if>
1049+
<available file="./${dir.publish}/${dir.images}/" type="dir" />
1050+
<then>
1051+
<delete>
1052+
<fileset dir="./${dir.publish}/${dir.images}/">
1053+
<include name="**/*.png"/>
1054+
</fileset>
1055+
</delete>
1056+
</then>
1057+
</if>
1058+
<!-- Run if available -->
1059+
<for param="image-dir">
1060+
<path>
1061+
<dirset dir="${dir.source}" includes="${dir.images}"/>
1062+
</path>
1063+
<sequential>
1064+
<property name="relative.image.dir" location="@{image-dir}" relative="yes"/>
1065+
1066+
<if>
1067+
<not>
1068+
<available file="${basedir}/${dir.publish}/${relative.image.dir}"/>
1069+
</not>
1070+
<then>
1071+
<copy todir="${dir.publish}/${relative.image.dir}">
1072+
<dirset dir="${dir.source}/${relative.image.dir}"/>
1073+
</copy>
1074+
</then>
1075+
</if>
1076+
1077+
<apply executable="${optipng.executable}" dest="./${dir.publish}/${relative.image.dir}/">
1078+
<fileset dir="./${dir.source}/${relative.image.dir}/" includes="**/*.png" excludes="${images.bypass}, ${images.default.bypass}"/>
1079+
<arg value="-quiet"/>
1080+
<arg value="-o7"/>
1081+
<arg value="-out"/>
1082+
<targetfile/>
1083+
<srcfile/>
1084+
<mapper type="identity"/>
1085+
</apply>
1086+
<var name="relative.image.dir" unset="true"/>
1087+
</sequential>
1088+
</for>
1089+
</then>
1090+
</if>
10401091
</else>
1092+
10411093
</if>
10421094
<!-- Let's do ADVPNG -->
10431095
<!-- On *nix's and OS X, check for advpng and give a helpful message if it's not installed -->
@@ -1086,7 +1138,7 @@
10861138
</then>
10871139
</if>
10881140

1089-
<apply executable="${advpng.executable}" dest="./${dir.publish}/${relative.image.dir}/" osfamily="${os.family}">
1141+
<apply executable="${advpng.executable}" dest="./${dir.publish}/${relative.image.dir}/">
10901142
<fileset dir="./${dir.publish}/${relative.image.dir}/" includes="**/*.png" excludes="${images.bypass}, ${images.default.bypass}"/>
10911143
<arg line="-z"/>
10921144
<arg line="-4"/>
@@ -1161,7 +1213,7 @@
11611213
</then>
11621214
</if>
11631215

1164-
<apply executable="${jpegtran.executable}" dest="./${dir.publish}/${relative.image.dir}" osfamily="${os.family}">
1216+
<apply executable="${jpegtran.executable}" dest="./${dir.publish}/${relative.image.dir}">
11651217
<fileset dir="${dir.source}/${relative.image.dir}" includes="**/*.jpg" excludes="${images.bypass}, ${images.default.bypass}"/>
11661218
<arg value="-copy"/>
11671219
<arg value="${retain-meta-tags}"/>

config/default.properties

+3-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ scripts.defer =
132132
#
133133
# Image Optimisation
134134
#
135-
images.strip.metadata = false
135+
images.strip.metadata = true
136136
# Seting this to true will strip the metadata from all jpeg and png files.
137137
##
138138
# Bypass Optimization for these image files or folders
@@ -141,7 +141,8 @@ images.strip.metadata = false
141141
# If set, these images will not be optimized
142142
# Note: you cannot declare an empty images.default.bypass property
143143
# use progressive jpegs?
144-
images.opts.progressive =
144+
images.opts.progressive =
145+
# We're assuming you have an optipng version greater than 7.0
145146
images.optipng.newer = true
146147
# Rev Image Filenames within the main stylesheet
147148
css.rev.images = true

0 commit comments

Comments
 (0)