Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
e9f0a388
Unverified
Commit
e9f0a388
authored
4 years ago
by
Joas Schilling
Browse files
Options
Downloads
Patches
Plain Diff
Allow to specify a directory and skip node_modules and tests
Signed-off-by:
Joas Schilling
<
coding@schilljs.com
>
parent
e49b6c57
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
build/image-optimization.sh
+35
-9
35 additions, 9 deletions
build/image-optimization.sh
with
35 additions
and
9 deletions
build/image-optimization.sh
+
35
−
9
View file @
e9f0a388
#!/usr/bin/env bash
CHECK_DIR
=
'../'
if
!
[
"
$SERVER_VERSION
"
]
;
then
CHECK_DIR
=
$1
fi
function
recursive_optimize_images
()
{
cd
"
$1
"
||
return
DIR_NAME
=
${
PWD
##*/
}
if
[[
"
$DIR_NAME
"
==
"node_modules"
]]
;
then
return
elif
[[
"
$DIR_NAME
"
==
"tests"
]]
;
then
return
fi
# Optimize all PNGs
for
png
in
*
.png
do
[[
-e
"
$png
"
]]
||
break
optipng
-o6
-strip
all
"
$png
"
done
# Optimize all JPGs and PNGs
optipng
-o6
-strip
all
*
.png
jpegoptim
--strip-all
*
.jpg
# Optimize all JPGs
for
jpg
in
*
.jpg
do
[[
-e
"
$jpg
"
]]
||
break
jpegoptim
--strip-all
"
$jpg
"
done
# Optimize all SVGs
for
svg
in
*
.svg
do
mv
$svg
$svg
.opttmp
;
[[
-e
"
$svg
"
]]
||
break
mv
$svg
$svg
.opttmp
scour
--create-groups
\
--enable-id-stripping
\
--enable-comment-stripping
\
...
...
@@ -20,19 +46,19 @@ function recursive_optimize_images() {
--no-line-breaks
\
-i
$svg
.opttmp
\
-o
$svg
rm
$svg
.opttmp
done
# Remove temporary SVGs
rm
*
.opttmp
# Check all subfolders
for
dir
in
*
/
do
if
[[
-d
"
$DIR
"
]]
;
then
[[
-e
"
$dir
"
]]
||
break
if
[[
-d
"
$dir
"
]]
;
then
recursive_optimize_images
"
$dir
"
cd
..
fi
done
}
recursive_optimize_images
../
recursive_optimize_images
"
$CHECK_DIR
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment