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

Commit ccb7913

Browse files
committed
Reworked the two PNG tasks.
This will close #163 Image Optimization Broken on Linux/Mac #147 OptiPNG with unix #141 You have optipng installed and your version is: usage: grep (Mac OS Lion Mountain) #149 - fix optipng version regex
1 parent 2eb8919 commit ccb7913

File tree

3 files changed

+39
-55
lines changed

3 files changed

+39
-55
lines changed

build.xml

+35-55
Original file line numberDiff line numberDiff line change
@@ -954,55 +954,36 @@
954954
<echo message=" "/>
955955
<echo message="First, we run optipng on the .png files..."/>
956956

957-
<!-- By default set strip-meta-tags to empty -->
958-
<var name="strip-meta-tags" value=""/>
959-
960957
<if>
961958
<equals arg1="${images.strip.metadata}" arg2="true"/>
962959
<then>
963-
<var name="strip-meta-tags" value="-strip all"/>
960+
<var name="strip-meta-tags" value="-strip all"/>
964961
</then>
962+
<else>
963+
<var name="strip-meta-tags" value="-strip all"/>
964+
</else>
965965
</if>
966966

967-
<!-- By default set os.family to windows, and optipng as available and it's executable -->
968-
<var name="os.family" value="windows"/>
969-
<var name="optipng.available" value="true"/>
970-
<var name="optipng.executable" value="${basedir}/${dir.build.tools}/${tool.optipng}"/>
971-
972-
<!-- osfamily=unix is actually true on OS X as well -->
973-
<!-- On *nix's and OS X, check for optipng and give a helpful message if it's not installed -->
974-
<if>
975-
<os family="unix"/>
976-
<then>
967+
968+
<if>
969+
<os family="windows"/>
970+
<then>
971+
<var name="optipng.available" value="true"/>
972+
<var name="optipng.executable" value="${basedir}/${dir.build.tools}/${tool.optipng}"/>
973+
</then>
974+
<else>
977975
<if>
978-
<!-- Then check for availability if unix -->
979-
<available file="optipng" filepath="${ENV.PATH}"/>
980-
<then>
981-
<var name="optipng.executable" value="optipng"/>
982-
<shellscript shell="bash" outputproperty="optipng.version">
983-
optipng -version | grep -Po 'OptiPNG\s(version\s)?\d\.\d' | grep -Po '\d\.\d'
984-
</shellscript>
985-
<echo message="You have optipng installed and your version is: ${optipng.version}"/>
986-
</then>
987-
<else>
988-
<var name="optipng.available" value="false"/>
989-
</else>
976+
<!-- Then check for availability if unix -->
977+
<available file="optipng" filepath="${ENV.PATH}"/>
978+
<var name="optipng.executable" value="optipng"/>
979+
<if>
980+
<equals arg1="${images.optipng.newer}" arg2="true"/>
981+
<var name="optipng.available" value="true"/>
982+
</if>
990983
</if>
991-
<if>
992-
<equals arg1="${optipng.version}" arg2="0.7"/>
993-
<then>
994-
<var name="optipng.executable" value="optipng"/>
995-
</then>
996-
<else>
997-
<var name="optipng.available" value="false"/>
998-
</else>
999-
</if>
1000-
1001-
<!-- Temporarily fixes #39 -->
1002-
<var name="strip-meta-tags" value=""/>
1003-
</then>
1004-
</if>
1005-
984+
</else>
985+
</if>
986+
1006987
<!-- Now check for availability -->
1007988
<if>
1008989
<equals arg1="${optipng.available}" arg2="true"/>
@@ -1018,7 +999,6 @@
1018999
</delete>
10191000
</then>
10201001
</if>
1021-
10221002
<!-- Run if available -->
10231003
<for param="image-dir">
10241004
<path>
@@ -1063,16 +1043,14 @@
10631043
<!-- On *nix's and OS X, check for advpng and give a helpful message if it's not installed -->
10641044

10651045
<echo message="Now, we run advpng on the .png files..."/>
1066-
<!-- By default set os.family to windows, and optipng as available and it's executable -->
1067-
<var name="os.family" value="windows"/>
1068-
<var name="advpng.available" value="true"/>
1069-
<var name="advpng.executable" value="${basedir}/${dir.build.tools}/${tool.advpng}"/>
1070-
1071-
<!-- osfamily=unix is actually true on OS X as well -->
1072-
<!-- On *nix's and OS X, check for optipng and give a helpful message if it's not installed -->
1073-
<if>
1074-
<os family="unix"/>
1075-
<then>
1046+
1047+
<if>
1048+
<os family="windows"/>
1049+
<then>
1050+
<var name="advpng.available" value="true"/>
1051+
<var name="advpng.executable" value="${basedir}/${dir.build.tools}/${tool.advpng}"/>
1052+
</then>
1053+
<else>
10761054
<if>
10771055
<!-- Then check for availability if unix -->
10781056
<available file="advpng" filepath="${ENV.PATH}"/>
@@ -1083,9 +1061,10 @@
10831061
<var name="advpng.available" value="false"/>
10841062
</else>
10851063
</if>
1086-
</then>
1087-
</if>
1088-
1064+
</else>
1065+
</if>
1066+
1067+
10891068
<!-- Now check for availability -->
10901069
<if>
10911070
<equals arg1="${advpng.available}" arg2="true"/>
@@ -1126,6 +1105,7 @@
11261105
</else>
11271106
</if>
11281107
</target>
1108+
11291109
<target name="-imagesjpg" depends="-mkdirs" description="(PRIVATE) Optimizes .jpg images using jpegtan">
11301110
<echo message="Now, we clean up those jpgs..."/>
11311111

config/default.properties

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ images.strip.metadata = false
142142
# Note: you cannot declare an empty images.default.bypass property
143143
# use progressive jpegs?
144144
images.opts.progressive =
145+
images.optipng.newer = true
145146
# Rev Image Filenames within the main stylesheet
146147
css.rev.images = true
147148
# Rev Image Filenames within the HTML files.

config/project.properties

+3
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ env =
184184
##
185185
# uncomment this to enable progressive jpg conversion using jpegtran
186186
# images.opts.progressive = -progressive
187+
#
188+
# uncomment this if you have an older version of optipng < 0.7
189+
# images.optipng.newer = false
187190
#---------------------------------------#
188191
# Misc #
189192
#---------------------------------------#

0 commit comments

Comments
 (0)