Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P7049
Manual thumbnail generation script
Active
Public
Actions
Authored by
Samwilson
on Apr 29 2018, 4:02 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
#!/bin/bash
#
# This script will manually generate thumbnails for MediaWiki. It's useful for memory-constrained
# environments such as shared hosting where you might have to resort to generating the thumbnails
# on a another machine and then uploading them manually. See also:
# https://www.mediawiki.org/wiki/Manual:Errors_and_symptoms#Manually_adding_thumbnail_files
#
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
mkdir -p
$(
dirname
"
$DEST
"
)
convert -resize
$WIDTH
"
$SRC
"
"
$DEST
"
fi
Event Timeline
Samwilson
created this paste.
Apr 29 2018, 4:02 AM
2018-04-29 04:02:28 (UTC+0)
Samwilson
edited the content of this paste.
(Show Details)
Apr 29 2018, 4:04 AM
2018-04-29 04:04:44 (UTC+0)
Samwilson
edited the content of this paste.
(Show Details)
May 6 2019, 10:42 PM
2019-05-06 22:42:15 (UTC+0)
Samwilson
edited the content of this paste.
(Show Details)
Jun 5 2020, 12:21 AM
2020-06-05 00:21:50 (UTC+0)
Log In to Comment