Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F17387031
Manual thumbnail generation script
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
Samwilson
Apr 29 2018, 4:02 AM
2018-04-29 04:02:28 (UTC+0)
Size
590 B
Referenced Files
None
Subscribers
None
Manual thumbnail generation script
View Options
#!/bin/bash
USAGE
=
"Usage: "
$(
basename
$0
)
" <sourcefile> <width>"
if
[
! -f
"
$1
"
]
;
then
echo
"Error: first parameter must be a file path."
>
&
2
echo
$USAGE
exit
1
fi
if
!
[[
"
$2
"
=
~ ^
[
0
-9
]
+$
]]
;
then
echo
"Error: second parameter must be an integer."
>
&
2
echo
$USAGE
exit
1
fi
SRC
=
"
$1
"
WIDTH
=
$2
RELSRC
=
$(
echo
$SRC
|
rev
|
cut -d/ -f1-3
|
rev
)
DEST
=
$(
dirname
$(
dirname
$(
dirname
$SRC
)))
"/thumb/"
$RELSRC
"/"
$WIDTH
"px-"
$(
basename
"
$SRC
"
)
echo
"Create this file?"
echo
$DEST
echo
-n
"[y/n]: "
read
if
[[
$REPLY
=
~ ^
[
Yy
]
$
]]
then
echo
convert -resize
$WIDTH
"
$SRC
"
"
$DEST
"
fi
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5780287
Default Alt Text
Manual thumbnail generation script (590 B)
Attached To
Mode
P7049 Manual thumbnail generation script
Attached
Detach File
Event Timeline
Log In to Comment