Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P2540
jpeg:size in wand
Active
Public
Actions
Authored by
•
Gilles
on Jan 28 2016, 11:27 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F3289426: jpeg:size in wand
Feb 24 2016, 5:27 AM
2016-02-24 05:27:50 (UTC+0)
Subscribers
None
import
os
,
resource
,
sys
import
wand.image
as
image
image
.
OPTIONS
=
frozenset
([
'fill'
,
'jpeg:sampling-factor'
,
'pdf:use-cropbox'
,
'jpeg:size'
])
def
utime
():
return
resource
.
getrusage
(
resource
.
RUSAGE_SELF
)
.
ru_utime
+
resource
.
getrusage
(
resource
.
RUSAGE_CHILDREN
)
.
ru_utime
size
=
98
,
72
for
infile
in
sys
.
argv
[
1
:]:
outfile
=
os
.
path
.
splitext
(
infile
)[
0
]
+
".thumbnail.jpg"
if
infile
!=
outfile
:
try
:
with
image
.
Image
()
as
im
:
im
.
options
[
'jpeg:size'
]
=
'98x72'
im
.
read
(
filename
=
infile
)
start
=
utime
()
im
.
resize
(
98
,
72
)
duration
=
utime
()
-
start
duration
=
int
(
round
(
duration
*
1000
,
0
))
print
"Utime:
%r
"
%
duration
im
.
save
(
filename
=
outfile
)
except
IOError
:
print
"cannot create thumbnail for '
%s
'"
%
infile
Event Timeline
•
Gilles
changed the title of this paste from untitled to
jpeg:size in wand
.
Jan 28 2016, 11:27 PM
2016-01-28 23:27:30 (UTC+0)
•
Gilles
updated the paste's language from
autodetect
to
python
.
•
Gilles
edited the content of this paste.
(Show Details)
•
Gilles
mentioned this in
T125167: ImageMagick engine
.
Jan 28 2016, 11:38 PM
2016-01-28 23:38:52 (UTC+0)
•
RobLa-WMF
mentioned this in
T127329: Using Parsoid as a wikitext bridge for importing content into wikitext format
.
Mar 6 2016, 12:45 AM
2016-03-06 00:45:10 (UTC+0)
Log In to Comment