image_optim_pack 0.12.0-arm64-darwin
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.dockerignore +10 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/build.yml +47 -0
- data/.github/workflows/check.yml +33 -0
- data/.github/workflows/docker-build.yml +29 -0
- data/.github/workflows/livecheck.yml +35 -0
- data/.github/workflows/rubocop.yml +16 -0
- data/.gitignore +7 -0
- data/.rubocop.yml +97 -0
- data/CHANGELOG.markdown +546 -0
- data/Dockerfile +184 -0
- data/Dockerfile.debian +184 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +27 -0
- data/Makefile +543 -0
- data/README.markdown +121 -0
- data/acknowledgements/7z.txt +56 -0
- data/acknowledgements/advancecomp.txt +674 -0
- data/acknowledgements/bmp2png.txt +8 -0
- data/acknowledgements/cexcept.txt +8 -0
- data/acknowledgements/gifread.txt +14 -0
- data/acknowledgements/gifsicle.txt +343 -0
- data/acknowledgements/iqa.txt +30 -0
- data/acknowledgements/jhead.txt +12 -0
- data/acknowledgements/jpeg-archive.txt +20 -0
- data/acknowledgements/jpegoptim.txt +339 -0
- data/acknowledgements/libjpeg-turbo.txt +27 -0
- data/acknowledgements/libjpeg-x86-simd.txt +17 -0
- data/acknowledgements/libjpeg.txt +64 -0
- data/acknowledgements/liblcms2.txt +21 -0
- data/acknowledgements/libpng.txt +90 -0
- data/acknowledgements/mozjpeg.txt +7 -0
- data/acknowledgements/optipng-authors.txt +26 -0
- data/acknowledgements/optipng.txt +21 -0
- data/acknowledgements/oxipng.txt +20 -0
- data/acknowledgements/pngcrush.txt +35 -0
- data/acknowledgements/pngout.txt +9 -0
- data/acknowledgements/pngquant.txt +56 -0
- data/acknowledgements/smallfry.txt +13 -0
- data/acknowledgements/zlib.txt +34 -0
- data/acknowledgements/zopfli-contributors.txt +6 -0
- data/acknowledgements/zopfli.txt +201 -0
- data/checksums.mk +17 -0
- data/image_optim_pack-darwin-arm64.gemspec +3 -0
- data/image_optim_pack-darwin-x86_64.gemspec +3 -0
- data/image_optim_pack-linux-x86_64.gemspec +3 -0
- data/image_optim_pack.gemspec +62 -0
- data/lib/image_optim/pack.rb +119 -0
- data/lib/image_optim_pack.rb +3 -0
- data/patches/pngcrush.patch +15 -0
- data/script/extract +19 -0
- data/script/livecheck +263 -0
- data/script/platform_downloads +59 -0
- data/script/run +131 -0
- data/spec/image_optim/pack_spec.rb +116 -0
- data/spec/image_optim_spec.rb +42 -0
- data/spec/spec_helper.rb +10 -0
- data/vendor/darwin-arm64/advpng +0 -0
- data/vendor/darwin-arm64/gifsicle +0 -0
- data/vendor/darwin-arm64/jhead +0 -0
- data/vendor/darwin-arm64/jpeg-recompress +0 -0
- data/vendor/darwin-arm64/jpegoptim +0 -0
- data/vendor/darwin-arm64/jpegtran +0 -0
- data/vendor/darwin-arm64/libjpeg.dylib +0 -0
- data/vendor/darwin-arm64/liblcms2.dylib +0 -0
- data/vendor/darwin-arm64/libpng.dylib +0 -0
- data/vendor/darwin-arm64/libz.dylib +0 -0
- data/vendor/darwin-arm64/optipng +0 -0
- data/vendor/darwin-arm64/oxipng +0 -0
- data/vendor/darwin-arm64/pngcrush +0 -0
- data/vendor/darwin-arm64/pngout +0 -0
- data/vendor/darwin-arm64/pngquant +0 -0
- metadata +199 -0
data/Makefile
ADDED
@@ -0,0 +1,543 @@
|
|
1
|
+
all :
|
2
|
+
|
3
|
+
# ====== VERSIONS ======
|
4
|
+
|
5
|
+
ADVANCECOMP_VER := 2.6
|
6
|
+
GIFSICLE_VER := 1.95
|
7
|
+
JHEAD_VER := 3.04
|
8
|
+
JPEGARCHIVE_VER := 2.2.0
|
9
|
+
JPEGOPTIM_VER := 1.5.5
|
10
|
+
LIBJPEG_VER := 9f
|
11
|
+
LIBLCMS_VER := 2.17
|
12
|
+
LIBMOZJPEG_VER := 4.1.5
|
13
|
+
LIBPNG_VER := 1.6.47
|
14
|
+
LIBZ_VER := 1.2.11
|
15
|
+
OPTIPNG_VER := 0.7.8
|
16
|
+
OXIPNG_VER := 9.1.4
|
17
|
+
PNGCRUSH_VER := 1.8.13
|
18
|
+
PNGOUT_VER = $(if $(IS_DARWIN),$(PNGOUT_DARWIN_VER),$(PNGOUT_LINUX_VER))
|
19
|
+
PNGOUT_LINUX_VER := 20200115
|
20
|
+
PNGOUT_LINUX_STATIC_VER := $(PNGOUT_LINUX_VER)
|
21
|
+
PNGOUT_DARWIN_VER := 20230322
|
22
|
+
PNGQUANT_VER := 3.0.3
|
23
|
+
|
24
|
+
# ====== CHECKSUMS ======
|
25
|
+
|
26
|
+
include checksums.mk
|
27
|
+
|
28
|
+
# ====== CONSTANTS ======
|
29
|
+
|
30
|
+
OS := $(shell uname -s | tr A-Z a-z)
|
31
|
+
HOST_ARCH := $(shell uname -m)
|
32
|
+
ARCH := $(HOST_ARCH)
|
33
|
+
|
34
|
+
IS_DARWIN := $(findstring darwin,$(OS))
|
35
|
+
IS_LINUX := $(findstring linux,$(OS))
|
36
|
+
IS_BSD := $(findstring bsd,$(OS))
|
37
|
+
IS_FREEBSD := $(findstring freebsd,$(OS))
|
38
|
+
IS_OPENBSD := $(findstring openbsd,$(OS))
|
39
|
+
DLEXT := $(if $(IS_DARWIN),.dylib,.so)
|
40
|
+
HOST := $(ARCH:arm64=arm)-$(if $(IS_DARWIN),apple,pc)-$(OS)
|
41
|
+
RUST_HOST := $(ARCH:arm64=aarch64)-$(if $(IS_DARWIN),apple-darwin,unknown-linux-gnu)
|
42
|
+
|
43
|
+
DL_DIR := $(CURDIR)/download
|
44
|
+
BUILD_ROOT_DIR := $(CURDIR)/build
|
45
|
+
BUILD_DIR := $(BUILD_ROOT_DIR)/$(OS)-$(ARCH)
|
46
|
+
OUTPUT_ROOT_DIR := $(CURDIR)/vendor
|
47
|
+
OUTPUT_DIR := $(OUTPUT_ROOT_DIR)/$(OS)-$(ARCH)
|
48
|
+
PATCHES_DIR := $(CURDIR)/patches
|
49
|
+
|
50
|
+
export CARGO_HOME := $(DL_DIR)/cargo
|
51
|
+
|
52
|
+
ANSI_RED=\033[31m
|
53
|
+
ANSI_GREEN=\033[32m
|
54
|
+
ANSI_MAGENTA=\033[35m
|
55
|
+
ANSI_RESET=\033[0m
|
56
|
+
|
57
|
+
# ====== HELPERS ======
|
58
|
+
|
59
|
+
downcase = $(shell echo $1 | tr A-Z a-z)
|
60
|
+
|
61
|
+
tar := $(shell if command -v bsdtar >/dev/null 2>&1; then echo bsdtar; else echo tar; fi)
|
62
|
+
sha256sum := $(shell if command -v sha256sum >/dev/null 2>&1; then echo sha256sum; elif command -v shasum >/dev/null 2>&1; then echo shasum -a 256; else echo sha256; fi)
|
63
|
+
|
64
|
+
# ====== ARCHIVES ======
|
65
|
+
|
66
|
+
ARCHIVES :=
|
67
|
+
|
68
|
+
# $1 - name of archive
|
69
|
+
# $2 - extension to use (instead of default tar.gz)
|
70
|
+
define archive
|
71
|
+
ARCHIVES += $1
|
72
|
+
$1_DIR := $(BUILD_DIR)/$(call downcase,$1)
|
73
|
+
$1_ARC := $(DL_DIR)/$(call downcase,$1)-$($1_VER).$(or $2,tar.gz)
|
74
|
+
$1_EXTRACTED := $$($1_DIR)/__$$(notdir $$($1_ARC))__
|
75
|
+
$$($1_EXTRACTED) : $$($1_ARC)
|
76
|
+
mkdir -p $(BUILD_DIR)
|
77
|
+
rm -rf $$(@D)
|
78
|
+
echo "$$($1_SHA256) $$<" | $(sha256sum) -c
|
79
|
+
mkdir $$(@D)
|
80
|
+
$(tar) -C $$(@D) --strip-components=1 -xzf $$<
|
81
|
+
touch $$(@D)/__$$(notdir $$<)__
|
82
|
+
endef
|
83
|
+
|
84
|
+
# $1 - name of archive
|
85
|
+
# $2 - url of archive with [VER] for replace with version
|
86
|
+
# $3 - extension to use
|
87
|
+
define archive-dl
|
88
|
+
$(call archive,$1,$3)
|
89
|
+
# download archive from url
|
90
|
+
$$($1_ARC) :
|
91
|
+
mkdir -p $(DL_DIR)
|
92
|
+
test -w $(DL_DIR)
|
93
|
+
while ! mkdir $$@.lock 2> /dev/null; do sleep 1; done
|
94
|
+
wget -q -O $$@.tmp $(subst [VER],$($1_VER),$(strip $2))
|
95
|
+
mv $$@.tmp $$@
|
96
|
+
rm -r $$@.lock
|
97
|
+
endef
|
98
|
+
|
99
|
+
$(eval $(call archive-dl,ADVANCECOMP, https://github.com/amadvance/advancecomp/releases/download/v[VER]/advancecomp-[VER].tar.gz))
|
100
|
+
$(eval $(call archive-dl,GIFSICLE, https://www.lcdf.org/gifsicle/gifsicle-[VER].tar.gz))
|
101
|
+
$(eval $(call archive-dl,JHEAD, https://www.sentex.ca/~mwandel/jhead/jhead-[VER].tar.gz))
|
102
|
+
$(eval $(call archive-dl,JPEGARCHIVE, https://github.com/danielgtaylor/jpeg-archive/archive/v[VER].tar.gz))
|
103
|
+
$(eval $(call archive-dl,JPEGOPTIM, https://github.com/tjko/jpegoptim/archive/v[VER].tar.gz))
|
104
|
+
$(eval $(call archive-dl,LIBJPEG, https://www.ijg.org/files/jpegsrc.v[VER].tar.gz))
|
105
|
+
$(eval $(call archive-dl,LIBLCMS, https://prdownloads.sourceforge.net/lcms/lcms2-[VER].tar.gz?download))
|
106
|
+
$(eval $(call archive-dl,LIBMOZJPEG, https://github.com/mozilla/mozjpeg/archive/v[VER].tar.gz))
|
107
|
+
$(eval $(call archive-dl,LIBPNG, https://prdownloads.sourceforge.net/libpng/libpng-[VER].tar.gz?download))
|
108
|
+
$(eval $(call archive-dl,LIBZ, https://prdownloads.sourceforge.net/libpng/zlib-[VER].tar.gz?download))
|
109
|
+
$(eval $(call archive-dl,OPTIPNG, https://prdownloads.sourceforge.net/optipng/optipng-[VER].tar.gz?download))
|
110
|
+
$(eval $(call archive-dl,OXIPNG, https://github.com/shssoichiro/oxipng/archive/refs/tags/v[VER].tar.gz))
|
111
|
+
$(eval $(call archive-dl,PNGCRUSH, https://prdownloads.sourceforge.net/pmt/pngcrush-[VER]-nolib.tar.gz?download))
|
112
|
+
$(eval $(call archive-dl,PNGOUT_LINUX,https://www.jonof.id.au/files/kenutils/pngout-[VER]-linux.tar.gz))
|
113
|
+
$(eval $(call archive-dl,PNGOUT_LINUX_STATIC,https://www.jonof.id.au/files/kenutils/pngout-[VER]-linux-static.tar.gz))
|
114
|
+
$(eval $(call archive-dl,PNGOUT_DARWIN,https://www.jonof.id.au/files/kenutils/pngout-[VER]-mac.zip,zip))
|
115
|
+
$(eval $(call archive-dl,PNGQUANT, https://crates.io/api/v1/crates/pngquant/[VER]/download))
|
116
|
+
|
117
|
+
download : $(foreach archive,$(ARCHIVES),$($(archive)_ARC))
|
118
|
+
.PHONY : download
|
119
|
+
|
120
|
+
download-dependencies : $(OXIPNG_EXTRACTED) $(PNGQUANT_EXTRACTED)
|
121
|
+
cd $(OXIPNG_DIR) && cargo fetch --locked
|
122
|
+
cd $(PNGQUANT_DIR) && cargo fetch --locked
|
123
|
+
.PHONY : download-dependencies
|
124
|
+
|
125
|
+
download-tidy-up :
|
126
|
+
rm -f $(filter-out $(foreach archive,$(ARCHIVES),$($(archive)_ARC)),$(wildcard $(DL_DIR)/*.*))
|
127
|
+
.PHONY : download-tidy-up
|
128
|
+
|
129
|
+
checksum : download
|
130
|
+
@$(sha256sum) $(foreach archive,$(ARCHIVES),$($(archive)_ARC))
|
131
|
+
.PHONY : checksum
|
132
|
+
|
133
|
+
checksum-verify : download
|
134
|
+
@printf '%s %s\n' $(foreach archive,$(ARCHIVES),$($(archive)_SHA256) $($(archive)_ARC)) | $(sha256sum) -c
|
135
|
+
.PHONY : checksum-verify
|
136
|
+
|
137
|
+
checksum-update : download
|
138
|
+
@printf '%s := %s\n' $(foreach archive,$(ARCHIVES),$(archive)_SHA256 $(shell $(sha256sum) $($(archive)_ARC) | cut -d ' ' -f 1)) > checksums.mk
|
139
|
+
.PHONY : checksum-update
|
140
|
+
|
141
|
+
# ====== PRODUCTS ======
|
142
|
+
|
143
|
+
PRODUCTS :=
|
144
|
+
|
145
|
+
# $1 - product name
|
146
|
+
# $2 - archive name ($1 if empty)
|
147
|
+
# $3 - path ($1 if empty)
|
148
|
+
define target-build
|
149
|
+
$1_PATH := $(or $3,$(call downcase,$1))
|
150
|
+
$1_BASENAME := $$(notdir $$($1_PATH))
|
151
|
+
$1_DIR := $($(or $2,$1)_DIR)
|
152
|
+
$1_ARC := $($(or $2,$1)_ARC)
|
153
|
+
$1_EXTRACTED := $($(or $2,$1)_EXTRACTED)
|
154
|
+
$1_TARGET := $$($1_DIR)/$$($1_PATH)
|
155
|
+
$$($1_TARGET) : DIR := $$($1_DIR)
|
156
|
+
$$($1_TARGET) : $$($1_EXTRACTED)
|
157
|
+
endef
|
158
|
+
|
159
|
+
# $1 - product name
|
160
|
+
# $2 - archive name ($1 if empty)
|
161
|
+
# $3 - basename ($1 if empty)
|
162
|
+
# $4 - don't strip the target
|
163
|
+
define target
|
164
|
+
$(call target-build,$1,$2,$3)
|
165
|
+
PRODUCTS += $1
|
166
|
+
$1_DESTINATION := $$(OUTPUT_DIR)/$$($1_BASENAME)
|
167
|
+
# copy product to output dir
|
168
|
+
$$($1_DESTINATION) : $$($1_TARGET)
|
169
|
+
mkdir -p $(OUTPUT_DIR)
|
170
|
+
temppath=`mktemp "$(BUILD_DIR)"/tmp.XXXXXXXXXX` && \
|
171
|
+
$(if $4,cp $$< "$$$$temppath",strip $$< -Sx -o "$$$$temppath") && \
|
172
|
+
chmod 755 "$$$$temppath" && \
|
173
|
+
mv "$$$$temppath" $$@
|
174
|
+
# short name target
|
175
|
+
$(call downcase,$1) : | $$($1_DESTINATION)
|
176
|
+
endef
|
177
|
+
|
178
|
+
$(eval $(call target,ADVPNG,ADVANCECOMP))
|
179
|
+
$(eval $(call target,GIFSICLE,,src/gifsicle))
|
180
|
+
$(eval $(call target,JHEAD))
|
181
|
+
$(eval $(call target,JPEG-RECOMPRESS,JPEGARCHIVE))
|
182
|
+
$(eval $(call target,JPEGOPTIM))
|
183
|
+
$(eval $(call target,JPEGTRAN,LIBJPEG,.libs/jpegtran))
|
184
|
+
$(eval $(call target,LIBJPEG,,libjpeg$(DLEXT)))
|
185
|
+
$(eval $(call target,LIBLCMS,,liblcms2$(DLEXT)))
|
186
|
+
$(eval $(call target-build,LIBMOZJPEG,,libjpeg.a))
|
187
|
+
$(eval $(call target,LIBPNG,,libpng$(DLEXT)))
|
188
|
+
$(eval $(call target,LIBZ,,libz$(DLEXT)))
|
189
|
+
$(eval $(call target,OPTIPNG,,src/optipng/optipng))
|
190
|
+
$(eval $(call target,OXIPNG,,target/$(RUST_HOST)/release/oxipng))
|
191
|
+
$(eval $(call target,PNGCRUSH))
|
192
|
+
ifdef IS_DARWIN
|
193
|
+
$(eval $(call target,PNGOUT,PNGOUT_DARWIN,,NOSTRIP))
|
194
|
+
else
|
195
|
+
$(eval $(call target,PNGOUT,PNGOUT_LINUX,,NOSTRIP))
|
196
|
+
endif
|
197
|
+
$(eval $(call target,PNGQUANT,,target/$(RUST_HOST)/release/pngquant))
|
198
|
+
|
199
|
+
# ====== TARGETS ======
|
200
|
+
|
201
|
+
all : build
|
202
|
+
ifeq ($(ARCH),$(HOST_ARCH))
|
203
|
+
@$(MAKE) test
|
204
|
+
else
|
205
|
+
@echo Skipping tests when compiling for different architecture
|
206
|
+
endif
|
207
|
+
.PHONY : all
|
208
|
+
|
209
|
+
build : $(call downcase,$(PRODUCTS))
|
210
|
+
.PHONY : build
|
211
|
+
|
212
|
+
ifdef IS_DARWIN
|
213
|
+
ldd := otool -L
|
214
|
+
else
|
215
|
+
ldd := ldd
|
216
|
+
endif
|
217
|
+
|
218
|
+
ldd-version :; $(ldd) --version
|
219
|
+
.PHONY : ldd-version
|
220
|
+
|
221
|
+
define check_exists
|
222
|
+
@test -f $(OUTPUT_DIR)/$1 || \
|
223
|
+
{ printf "%s: $(ANSI_RED)not found$(ANSI_RESET)\n" "$1"; exit 1; }
|
224
|
+
endef
|
225
|
+
|
226
|
+
define check_version
|
227
|
+
@$(OUTPUT_DIR)/$1 $2 | fgrep -q "$3" || \
|
228
|
+
{ printf "%s: $(ANSI_RED)Expected %s, got %s$(ANSI_RESET)\n" "$1" "$3" "$$($(OUTPUT_DIR)/$1 $2)"; exit 1; }
|
229
|
+
endef
|
230
|
+
|
231
|
+
define check_arch
|
232
|
+
@file -b $(OUTPUT_DIR)/$1 | fgrep -q '$(ARCH_STRING)' || \
|
233
|
+
{ printf "%s: $(ANSI_RED)Expected %s, got %s$(ANSI_RESET)\n" "$1" "$(ARCH_STRING)" "$$(file -b $(OUTPUT_DIR)/$1)"; exit 1; }
|
234
|
+
endef
|
235
|
+
|
236
|
+
define check_output
|
237
|
+
@printf "%s: $(ANSI_GREEN)%s$(ANSI_RESET) / $(ANSI_MAGENTA)%s$(ANSI_RESET)\n" "$1" "$3" "$(ARCH_STRING)"
|
238
|
+
endef
|
239
|
+
|
240
|
+
define check_shlib
|
241
|
+
@! $(ldd) $(OUTPUT_DIR)/$1 | egrep -o "[^: ]+/[^: ]+" | egrep -v "^(@loader_path|/lib|/lib64|/usr|$(OUTPUT_DIR))/"
|
242
|
+
endef
|
243
|
+
|
244
|
+
define check_lib
|
245
|
+
$(call check_exists,$1)
|
246
|
+
$(call check_arch,$1)
|
247
|
+
$(call check_output,$1,,-)
|
248
|
+
$(call check_shlib,$1)
|
249
|
+
endef
|
250
|
+
|
251
|
+
define check_bin
|
252
|
+
$(call check_exists,$1)
|
253
|
+
$(call check_version,$1,$2,$3)
|
254
|
+
$(call check_arch,$1)
|
255
|
+
$(call check_output,$1,,$3)
|
256
|
+
$(call check_shlib,$1)
|
257
|
+
endef
|
258
|
+
|
259
|
+
ifdef IS_DARWIN
|
260
|
+
test : ARCH_STRING := $(ARCH)
|
261
|
+
else ifeq (amd64,$(ARCH:x86_64=amd64))
|
262
|
+
test : ARCH_STRING := x86-64
|
263
|
+
endif
|
264
|
+
test :
|
265
|
+
$(if $(ARCH_STRING),,@echo Detecting 'ARCH $(ARCH) for OS $(OS) undefined'; false)
|
266
|
+
$(call check_bin,advpng,--version 2>&1,$(ADVANCECOMP_VER))
|
267
|
+
$(call check_bin,gifsicle,--version,$(GIFSICLE_VER))
|
268
|
+
$(call check_bin,jhead,-V,$(JHEAD_VER))
|
269
|
+
$(call check_bin,jpeg-recompress,--version,$(JPEGARCHIVE_VER))
|
270
|
+
$(call check_bin,jpegoptim,--version,$(JPEGOPTIM_VER))
|
271
|
+
$(call check_bin,jpegtran,-v - 2>&1,$(LIBJPEG_VER))
|
272
|
+
$(call check_lib,libjpeg$(DLEXT))
|
273
|
+
$(call check_lib,liblcms2$(DLEXT))
|
274
|
+
$(call check_lib,libpng$(DLEXT))
|
275
|
+
$(call check_lib,libz$(DLEXT))
|
276
|
+
$(call check_bin,optipng,--version,$(OPTIPNG_VER))
|
277
|
+
$(call check_bin,oxipng,--version,$(OXIPNG_VER))
|
278
|
+
$(call check_bin,pngcrush,-version 2>&1,$(PNGCRUSH_VER))
|
279
|
+
$(call check_bin,pngout,2>&1 | head -n 1,$(shell perl -mTime::Piece -e 'print Time::Piece->strptime("$(PNGOUT_VER)", "%Y%m%d")->strftime("%b %e %Y")'))
|
280
|
+
$(call check_bin,pngquant,--help,$(PNGQUANT_VER))
|
281
|
+
.PHONY : test
|
282
|
+
|
283
|
+
update-versions :
|
284
|
+
script/livecheck --update
|
285
|
+
make checksum-update
|
286
|
+
make download-dependencies
|
287
|
+
.PHONY : update-versions
|
288
|
+
|
289
|
+
# ====== DOCKER ======
|
290
|
+
|
291
|
+
DOCKER_IMAGE := ghcr.io/toy/image_optim
|
292
|
+
DOCKER_TAG := $(shell date +%Y%m%d)
|
293
|
+
DOCKER_FILE := Dockerfile
|
294
|
+
|
295
|
+
docker-build : download
|
296
|
+
@docker build \
|
297
|
+
--pull \
|
298
|
+
$(foreach archive,$(ARCHIVES),--build-arg $(archive)_VER=$($(archive)_VER) --build-arg $(archive)_SHA256=$($(archive)_SHA256)) \
|
299
|
+
-t $(DOCKER_IMAGE):latest$(DOCKER_TAG_SUFFIX) \
|
300
|
+
-f $(DOCKER_FILE) \
|
301
|
+
.
|
302
|
+
@docker tag \
|
303
|
+
$(DOCKER_IMAGE):latest$(DOCKER_TAG_SUFFIX) \
|
304
|
+
$(DOCKER_IMAGE):$(DOCKER_TAG)$(DOCKER_TAG_SUFFIX)
|
305
|
+
.PHONY : docker-build
|
306
|
+
|
307
|
+
docker-test : docker-build
|
308
|
+
@docker run \
|
309
|
+
--rm \
|
310
|
+
$(DOCKER_IMAGE):latest$(DOCKER_TAG_SUFFIX) \
|
311
|
+
--info
|
312
|
+
.PHONY : docker-test
|
313
|
+
|
314
|
+
docker-push : docker-test
|
315
|
+
@docker push $(DOCKER_IMAGE):latest$(DOCKER_TAG_SUFFIX)
|
316
|
+
@docker push $(DOCKER_IMAGE):$(DOCKER_TAG)$(DOCKER_TAG_SUFFIX)
|
317
|
+
.PHONY : docker-push
|
318
|
+
|
319
|
+
# ====== CLEAN ======
|
320
|
+
|
321
|
+
clean :
|
322
|
+
rm -rf $(BUILD_DIR)
|
323
|
+
rm -rf $(OUTPUT_DIR)
|
324
|
+
.PHONY : clean
|
325
|
+
|
326
|
+
clean-all :
|
327
|
+
rm -rf $(BUILD_ROOT_DIR)
|
328
|
+
rm -rf $(OUTPUT_ROOT_DIR)
|
329
|
+
.PHONY : clean-all
|
330
|
+
|
331
|
+
clobber : clean-all
|
332
|
+
rm -rf $(DL_DIR)
|
333
|
+
.PHONY : clobber
|
334
|
+
|
335
|
+
# ====== BUILD HELPERS ======
|
336
|
+
|
337
|
+
# $1 - name of product
|
338
|
+
# $2 - list of dependency products
|
339
|
+
define depend-build
|
340
|
+
# depend this product on every specified product
|
341
|
+
$($1_EXTRACTED) : $$(filter-out $($1_EXTRACTED),$(foreach dep,$2,$$($(dep)_EXTRACTED)))
|
342
|
+
$($1_TARGET) : $(foreach dep,$2,$$($(dep)_TARGET))
|
343
|
+
# add dependent product dir to CPATH, LIBRARY_PATH and PKG_CONFIG_PATH
|
344
|
+
$($1_TARGET) : export CPATH := $(subst $(eval) ,:,$(foreach dep,$2,$$($(dep)_DIR)))
|
345
|
+
$($1_TARGET) : export LIBRARY_PATH := $$(CPATH)
|
346
|
+
$($1_TARGET) : export PKG_CONFIG_PATH := $$(CPATH)
|
347
|
+
endef
|
348
|
+
|
349
|
+
# $1 - name of product
|
350
|
+
# $2 - list of dependency products
|
351
|
+
define depend
|
352
|
+
$(call depend-build,$1,$2)
|
353
|
+
# depend output of this product on output of every specified product
|
354
|
+
$$($1_DESTINATION) : $(foreach dep,$2,$$($(dep)_DESTINATION))
|
355
|
+
endef
|
356
|
+
|
357
|
+
pkgconfig_pwd = perl -pi -e 's/(?<=dir=).*/$$ENV{PWD}/'
|
358
|
+
|
359
|
+
libtool_target_soname = perl -pi -e 's/(?<=soname_spec=)".*"/"$(@F)"/ ; s/(?<=library_names_spec=)".*"/"\\\$$libname\\\$$shared_ext"/' -- libtool
|
360
|
+
|
361
|
+
ifdef IS_DARWIN
|
362
|
+
chrpath_origin =
|
363
|
+
else ifdef IS_OPENBSD
|
364
|
+
chrpath_origin = perl -pi -e 's/XORIGIN/\$$ORIGIN/' -- $1
|
365
|
+
else
|
366
|
+
chrpath_origin = chrpath -r '$$ORIGIN' $1
|
367
|
+
endif
|
368
|
+
|
369
|
+
ifdef IS_LINUX
|
370
|
+
XORIGIN := -Wl,-rpath,XORIGIN
|
371
|
+
else ifdef IS_BSD
|
372
|
+
XORIGIN := -Wl,-rpath,XORIGIN -Wl,-z,origin
|
373
|
+
else
|
374
|
+
XORIGIN :=
|
375
|
+
endif
|
376
|
+
|
377
|
+
# ====== ENV ======
|
378
|
+
|
379
|
+
ifdef IS_DARWIN
|
380
|
+
export CC := clang
|
381
|
+
export CXX := clang++
|
382
|
+
else
|
383
|
+
export CC := gcc
|
384
|
+
export CXX := g++
|
385
|
+
endif
|
386
|
+
|
387
|
+
GCC_FLAGS := -O3
|
388
|
+
STATIC_LIBGCC := $(shell if $(CC) -v 2>&1 | fgrep -q gcc; then echo -static-libgcc; fi)
|
389
|
+
|
390
|
+
export CFLAGS = $(GCC_FLAGS)
|
391
|
+
export CXXFLAGS = $(GCC_FLAGS)
|
392
|
+
export CPPFLAGS = $(GCC_FLAGS)
|
393
|
+
export LDFLAGS = $(GCC_FLAGS)
|
394
|
+
|
395
|
+
ifdef IS_DARWIN
|
396
|
+
export MACOSX_DEPLOYMENT_TARGET := 10.12
|
397
|
+
GCC_FLAGS += -arch $(ARCH)
|
398
|
+
CXXFLAGS += -stdlib=libc++
|
399
|
+
export CMAKE_OSX_ARCHITECTURES := $(ARCH)
|
400
|
+
endif
|
401
|
+
|
402
|
+
ifdef IS_BSD
|
403
|
+
autotool_version = $(shell printf '%s\n' /usr/local/bin/$1-* | egrep -o '[0-9][^-]+$$' | tail -n 1)
|
404
|
+
export AUTOCONF_VERSION := $(call autotool_version,autoconf)
|
405
|
+
export AUTOMAKE_VERSION := $(call autotool_version,automake)
|
406
|
+
endif
|
407
|
+
|
408
|
+
# ====== BUILD TARGETS ======
|
409
|
+
|
410
|
+
## advpng
|
411
|
+
$(eval $(call depend,ADVPNG,LIBZ))
|
412
|
+
$(ADVPNG_TARGET) :
|
413
|
+
cd $(DIR) && ./configure --host "$(HOST)" LDFLAGS="$(XORIGIN)"
|
414
|
+
cd $(DIR) && $(MAKE) advpng
|
415
|
+
$(call chrpath_origin,$@)
|
416
|
+
|
417
|
+
## gifsicle
|
418
|
+
$(GIFSICLE_TARGET) :
|
419
|
+
cd $(DIR) && ./configure --host "$(HOST)"
|
420
|
+
cd $(DIR) && $(MAKE) gifsicle
|
421
|
+
|
422
|
+
## jhead
|
423
|
+
$(JHEAD_TARGET) :
|
424
|
+
cd $(DIR) && $(MAKE) jhead CC="$(CC) $(CFLAGS)"
|
425
|
+
|
426
|
+
## jpeg-recompress
|
427
|
+
$(eval $(call depend-build,JPEG-RECOMPRESS,LIBMOZJPEG))
|
428
|
+
$(JPEG-RECOMPRESS_TARGET) :
|
429
|
+
cd $(DIR) && $(MAKE) jpeg-recompress CC="$(CC) $(CFLAGS) -fcommon" LIBJPEG=$(LIBMOZJPEG_TARGET) \
|
430
|
+
MAKE=$(MAKE) # fix for bsd in jpeg-archive-2.1.1
|
431
|
+
|
432
|
+
## jpegoptim
|
433
|
+
$(eval $(call depend,JPEGOPTIM,LIBJPEG))
|
434
|
+
$(JPEGOPTIM_TARGET) :
|
435
|
+
cd $(DIR) && ./configure --host "$(HOST)" LDFLAGS="$(XORIGIN)"
|
436
|
+
cd $(DIR) && $(MAKE) jpegoptim
|
437
|
+
$(call chrpath_origin,$@)
|
438
|
+
|
439
|
+
## jpegtran
|
440
|
+
$(eval $(call depend,JPEGTRAN,LIBJPEG))
|
441
|
+
$(JPEGTRAN_TARGET) :
|
442
|
+
cd $(DIR) && $(MAKE) jpegtran LDFLAGS="$(XORIGIN)"
|
443
|
+
$(call chrpath_origin,$(JPEGTRAN_TARGET))
|
444
|
+
|
445
|
+
## libjpeg
|
446
|
+
$(LIBJPEG_TARGET) :
|
447
|
+
cd $(DIR) && ./configure --host "$(HOST)" CC="$(CC) $(CFLAGS)"
|
448
|
+
cd $(DIR) && $(libtool_target_soname)
|
449
|
+
ifdef IS_DARWIN
|
450
|
+
cd $(DIR) && $(MAKE) libjpeg.la LDFLAGS="-Wl,-install_name,@loader_path/$(@F)"
|
451
|
+
else
|
452
|
+
cd $(DIR) && $(MAKE) libjpeg.la
|
453
|
+
endif
|
454
|
+
cd $(DIR) && ln -sf .libs/libjpeg$(DLEXT) .
|
455
|
+
|
456
|
+
## liblcms
|
457
|
+
$(LIBLCMS_TARGET) :
|
458
|
+
cd $(DIR) && ./configure --host "$(HOST)"
|
459
|
+
cd $(DIR) && $(libtool_target_soname)
|
460
|
+
ifdef IS_DARWIN
|
461
|
+
cd $(DIR)/src && make liblcms2.la LDFLAGS="-Wl,-install_name,@loader_path/$(@F)"
|
462
|
+
else
|
463
|
+
cd $(DIR)/src && make liblcms2.la LDFLAGS="$(XORIGIN)"
|
464
|
+
endif
|
465
|
+
cd $(DIR) && ln -sf include/lcms2.h .
|
466
|
+
cd $(DIR) && ln -sf src/.libs/liblcms2$(DLEXT) .
|
467
|
+
|
468
|
+
## libmozjpeg
|
469
|
+
$(LIBMOZJPEG_TARGET) :
|
470
|
+
cd $(DIR) && cmake -DPNG_SUPPORTED=0 .
|
471
|
+
cd $(DIR) && $(MAKE) jpeg-static
|
472
|
+
|
473
|
+
## libpng
|
474
|
+
$(eval $(call depend,LIBPNG,LIBZ))
|
475
|
+
$(LIBPNG_TARGET) :
|
476
|
+
cd $(DIR) && ./configure --host "$(HOST)" CC="$(CC) $(CFLAGS)"
|
477
|
+
cd $(DIR) && $(pkgconfig_pwd) -- *.pc
|
478
|
+
cd $(DIR) && perl -pi -e 's/(?<=lpng)\d+//g' -- *.pc # %MAJOR%%MINOR% suffix
|
479
|
+
cd $(DIR) && $(libtool_target_soname)
|
480
|
+
ifdef IS_DARWIN
|
481
|
+
cd $(DIR) && $(MAKE) libpng16.la LDFLAGS="-Wl,-install_name,@loader_path/$(@F)"
|
482
|
+
else
|
483
|
+
cd $(DIR) && $(MAKE) libpng16.la LDFLAGS="$(XORIGIN)"
|
484
|
+
endif
|
485
|
+
cd $(DIR) && ln -sf .libs/libpng16$(DLEXT) libpng$(DLEXT)
|
486
|
+
$(call chrpath_origin,$@)
|
487
|
+
|
488
|
+
## libz
|
489
|
+
ifdef IS_DARWIN
|
490
|
+
$(LIBZ_TARGET) : export LDSHARED = $(CC) -dynamiclib -install_name @loader_path/$(@F) -compatibility_version 1 -current_version $(LIBZ_VER)
|
491
|
+
else
|
492
|
+
$(LIBZ_TARGET) : export LDSHARED = $(CC) -shared -Wl,-soname,$(@F),--version-script,zlib.map
|
493
|
+
endif
|
494
|
+
$(LIBZ_TARGET) :
|
495
|
+
cd $(DIR) && ./configure
|
496
|
+
cd $(DIR) && $(pkgconfig_pwd) -- *.pc
|
497
|
+
cd $(DIR) && $(MAKE) placebo
|
498
|
+
|
499
|
+
## optipng
|
500
|
+
$(eval $(call depend,OPTIPNG,LIBPNG LIBZ))
|
501
|
+
$(OPTIPNG_TARGET) :
|
502
|
+
cd $(DIR) && ./configure -with-system-libs
|
503
|
+
cd $(DIR) && $(MAKE) all LDFLAGS="$(XORIGIN) $(LDFLAGS)"
|
504
|
+
$(call chrpath_origin,$@)
|
505
|
+
|
506
|
+
## oxipng
|
507
|
+
$(OXIPNG_TARGET) :
|
508
|
+
cd $(DIR) && cargo build --release --frozen --offline --target=$(RUST_HOST)
|
509
|
+
|
510
|
+
## pngcrush
|
511
|
+
$(eval $(call depend,PNGCRUSH,LIBPNG LIBZ))
|
512
|
+
$(PNGCRUSH_TARGET) :
|
513
|
+
cd $(DIR) && rm -f png.h pngconf.h
|
514
|
+
cd $(DIR) && patch < $(PATCHES_DIR)/pngcrush.patch
|
515
|
+
cd $(DIR) && $(MAKE) pngcrush \
|
516
|
+
CC="$(CC)" \
|
517
|
+
LD="$(CC)" \
|
518
|
+
LIBS="-lpng -lz -lm" \
|
519
|
+
CFLAGS="$(CFLAGS)" \
|
520
|
+
CPPFLAGS="$(CPPFLAGS)" \
|
521
|
+
LDFLAGS="$(XORIGIN) $(LDFLAGS)"
|
522
|
+
$(call chrpath_origin,$@)
|
523
|
+
|
524
|
+
## pngout
|
525
|
+
$(PNGOUT_TARGET) :
|
526
|
+
ifdef IS_LINUX
|
527
|
+
cd $(DIR) && ln -sf $(ARCH:x86_64=amd64)/pngout .
|
528
|
+
endif
|
529
|
+
cd $(DIR) && touch pngout
|
530
|
+
|
531
|
+
## pngquant
|
532
|
+
$(eval $(call depend,PNGQUANT,LIBLCMS LIBPNG LIBZ))
|
533
|
+
$(PNGQUANT_TARGET) : export OVERRIDE_BIN_DIR = $(LIBPNG_DIR)/override-bin
|
534
|
+
$(PNGQUANT_TARGET) : export PATH := $(OVERRIDE_BIN_DIR):$(PATH)
|
535
|
+
$(PNGQUANT_TARGET) : export RUSTFLAGS = -C link-arg=$(XORIGIN)
|
536
|
+
$(PNGQUANT_TARGET) :
|
537
|
+
# prevent build code of libpng-sys crate from using libpng-config
|
538
|
+
mkdir -p $(OVERRIDE_BIN_DIR) && \
|
539
|
+
cd $(OVERRIDE_BIN_DIR) && \
|
540
|
+
printf '%s\n' '#!/bin/sh' 'echo 1.5' > libpng-config && \
|
541
|
+
chmod +x libpng-config
|
542
|
+
cd $(DIR) && cargo build --release --frozen --offline --target=$(RUST_HOST)
|
543
|
+
$(call chrpath_origin,$@)
|
data/README.markdown
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
[](https://rubygems.org/gems/image_optim_pack)
|
2
|
+
[](https://github.com/toy/image_optim_pack/actions/workflows/check.yml)
|
3
|
+
[](https://github.com/toy/image_optim_pack/actions/workflows/rubocop.yml)
|
4
|
+
[](https://github.com/toy/image_optim_pack/actions/workflows/docker-build.yml)
|
5
|
+
[](https://github.com/toy/image_optim_pack/actions/workflows/livecheck.yml)
|
6
|
+
[](https://github.com/toy/image_optim_pack/actions/workflows/build.yml)
|
7
|
+
[](https://codeclimate.com/github/toy/image_optim_pack)
|
8
|
+
[](https://depfu.com/github/toy/image_optim_pack)
|
9
|
+
[](https://inch-ci.org/github/toy/image_optim_pack)
|
10
|
+
|
11
|
+
# image\_optim\_pack
|
12
|
+
|
13
|
+
Precompiled binaries for [`image_optim`](https://github.com/toy/image_optim).
|
14
|
+
|
15
|
+
Contains binaries for Mac OS X (>= 10.12, x86\_64, arm64) and Linux (x86\_64).
|
16
|
+
|
17
|
+
A test application with latest `image_optim` and `image_optim_pack` is available on render: https://iopack.onrender.com/.
|
18
|
+
|
19
|
+
## Binaries and libraries
|
20
|
+
|
21
|
+
* [advpng](https://www.advancemame.it/doc-advpng.html) by Andrea Mazzoleni and Filipe Estima ([GNU GPLv3](acknowledgements/advancecomp.txt))
|
22
|
+
* contains parts of [7z](https://7-zip.org) by Igor Pavlov with modifications by Andrea Mazzoleni ([license](acknowledgements/7z.txt))
|
23
|
+
* and [zopfli](https://code.google.com/p/zopfli/) by Lode Vandevenne and Jyrki Alakuijala ([license](acknowledgements/zopfli.txt), [contributors](acknowledgements/zopfli-contributors.txt))
|
24
|
+
* [gifsicle](https://lcdf.org/gifsicle/) by Eddie Kohler ([GNU GPLv2](acknowledgements/gifsicle.txt))
|
25
|
+
* [jhead](https://www.sentex.ca/~mwandel/jhead/) by Matthias Wandel ([public domain](acknowledgements/jhead.txt))
|
26
|
+
* [jpeg-recompress](https://github.com/danielgtaylor/jpeg-archive) by Daniel G. Taylor ([license](acknowledgements/jpeg-archive.txt))
|
27
|
+
* includes [Image Quality Assessment (IQA)](http://tdistler.com/iqa/) by Tom Distler ([license](acknowledgements/iqa.txt))
|
28
|
+
* includes [SmallFry](https://github.com/dwbuiten/smallfry) by Derek Buitenhuis ([license](acknowledgements/smallfry.txt))
|
29
|
+
* statically linked against mozjpeg, see below
|
30
|
+
* [jpegoptim](https://www.kokkonen.net/tjko/projects.html) by Timo Kokkonen ([GNU GPLv2](acknowledgements/jpegoptim.txt) or later)
|
31
|
+
* [libjpeg and jpegtran](https://ijg.org/) by the Independent JPEG Group ([license](acknowledgements/libjpeg.txt))
|
32
|
+
* [libjpeg-turbo](https://www.libjpeg-turbo.org/) by libjpeg-turbo Project ([license](acknowledgements/libjpeg-turbo.txt))
|
33
|
+
* based on libjpeg, see above
|
34
|
+
* includes [x86 SIMD extension for IJG JPEG library](https://cetus.sakura.ne.jp/softlab/jpeg-x86simd/jpegsimd.html) by Miyasaka Masaru ([license](acknowledgements/libjpeg-x86-simd.txt))
|
35
|
+
* [liblcms2](https://littlecms.com) by Marti Maria ([license](acknowledgements/liblcms2.txt))
|
36
|
+
* [libpng](http://libpng.org/pub/png/) by Guy Eric Schalnat, Andreas Dilger, Glenn Randers-Pehrson and others ([license](acknowledgements/libpng.txt))
|
37
|
+
* [mozjpeg](https://github.com/mozilla/mozjpeg) by Mozilla Research ([license](acknowledgements/mozjpeg.txt))
|
38
|
+
* base on libjpeg and libjpeg-turbo, see above
|
39
|
+
* [optipng](http://optipng.sourceforge.net/) by Cosmin Truta ([license](acknowledgements/optipng.txt), [authors](acknowledgements/optipng-authors.txt))
|
40
|
+
* contains code based in part on the work of Miyasaka Masaru for BMP support ([license](acknowledgements/bmp2png.txt))
|
41
|
+
* and David Koblas for GIF support ([license](acknowledgements/gifread.txt))
|
42
|
+
* [oxipng](https://github.com/shssoichiro/oxipng) by Joshua Holmer ([license](acknowledgements/oxipng.txt))
|
43
|
+
* [pngcrush](https://pmt.sourceforge.io/pngcrush/) by Glenn Randers-Pehrson, portions by Greg Roelofs ([license](acknowledgements/pngcrush.txt))
|
44
|
+
* contains [cexcept](http://www.nicemice.net/cexcept/) interface by Adam M. Costello and Cosmin Truta ([license](acknowledgements/cexcept.txt))
|
45
|
+
* [pngout](http://advsys.net/ken/utils.htm) by Ken Silverman ([license](acknowledgements/pngout.txt))
|
46
|
+
* Linux and BSD ports by Jonathon Fowler (http://www.jonof.id.au/pngout)
|
47
|
+
* Mac OS X port by Ken Silverman, with assistance by Jonathon Fowler
|
48
|
+
* [pngquant](https://pngquant.org/) by Kornel Lesiński based on code by Greg Roelofs and Jef Poskanzer after an idea by Stefan Schneider ([license](acknowledgements/pngquant.txt))
|
49
|
+
* [zlib](https://zlib.net/) by Jean-Loup Gailly and Mark Adler ([license](acknowledgements/zlib.txt))
|
50
|
+
|
51
|
+
**NOTE: On FreeBSD and OpenBSD `make` is not the GNU Make, so `gmake` should be used instead.**
|
52
|
+
|
53
|
+
You can download all source code using gnu make download target:
|
54
|
+
|
55
|
+
```sh
|
56
|
+
make download
|
57
|
+
```
|
58
|
+
|
59
|
+
## Installation
|
60
|
+
|
61
|
+
```sh
|
62
|
+
gem install image_optim image_optim_pack
|
63
|
+
```
|
64
|
+
|
65
|
+
Or add to your `Gemfile`:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
gem 'image_optim'
|
69
|
+
gem 'image_optim_pack'
|
70
|
+
```
|
71
|
+
|
72
|
+
## Development
|
73
|
+
|
74
|
+
Mac OS X binaries and libraries are built on host, others using containers.
|
75
|
+
|
76
|
+
```sh
|
77
|
+
script/run # Build and test all for all oses and architectures
|
78
|
+
script/run NO_HALT=1 # Don't halt VMs after building
|
79
|
+
script/run NO_UP=1 # Don't start VMs before building (will fail if not already running)
|
80
|
+
script/run darwin 64 # Build only platforms matching darwin or 64
|
81
|
+
|
82
|
+
make # Build all tools and copy them to vendor/OS-ARCH for current OS and ARCH, then test
|
83
|
+
make all # same
|
84
|
+
|
85
|
+
script/livecheck # Check versions
|
86
|
+
make update-versions # Update versions in Makefile
|
87
|
+
|
88
|
+
make download # Download archives
|
89
|
+
make download-tidy-up # Remove old archives
|
90
|
+
make build # Build all without copying to output directory
|
91
|
+
|
92
|
+
make test # Test bins for current os/arch
|
93
|
+
make test -i # Continue if one of bins fail
|
94
|
+
|
95
|
+
make clean # Remove build and output directories for current os/arch
|
96
|
+
make clean-all # Remove build root and output root directories
|
97
|
+
make clobber # `clean-all` and remove download directory
|
98
|
+
```
|
99
|
+
|
100
|
+
## Docker
|
101
|
+
|
102
|
+
This project includes a `Dockerfile` in the root, which builds a minimal image with most binaries included.
|
103
|
+
|
104
|
+
#### Running
|
105
|
+
|
106
|
+
```bash
|
107
|
+
docker run --rm ghcr.io/toy/image_optim --version # image_optim version
|
108
|
+
docker run --rm ghcr.io/toy/image_optim --info # image_optim info including bin versions
|
109
|
+
docker run --rm -v "$PWD":/here -w /here ghcr.io/toy/image_optim image-in-this-folder.jpg
|
110
|
+
```
|
111
|
+
|
112
|
+
#### Building
|
113
|
+
|
114
|
+
```bash
|
115
|
+
make docker-build # will be tagged with latest and current date in format %Y%m%d
|
116
|
+
make docker-push # will push tags created by docker-build
|
117
|
+
```
|
118
|
+
|
119
|
+
## Copyright
|
120
|
+
|
121
|
+
Copyright (c) 2014-2025 Ivan Kuchin. See [LICENSE.txt](LICENSE.txt) for details.
|