-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiscale images; specify output size #23
base: master
Are you sure you want to change the base?
Conversation
if args.scale: | ||
scale.apply_to_frames(cursor.frames, scale=args.scale) | ||
scales = eval(args.scale) | ||
if isinstance(scales, (int, float)): | ||
scale.apply_to_frames(cursor.frames, scale=scales) | ||
else: | ||
cursor.frames = scale.apply_to_frames_MS(cursor.frames, scales=scales) | ||
elif args.size: | ||
sizes = eval(args.size) | ||
if isinstance(sizes, (int, float)): | ||
scale.apply_to_frames(cursor.frames, size=sizes) | ||
else: | ||
cursor.frames = scale.apply_to_frames_MS(cursor.frames, sizes=sizes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use eval
. This is a security nightmare when using this in any form of automation.
if args.scale: | ||
scale.apply_to_frames(cursor.frames, scale=args.scale) | ||
scales = eval(args.scale) | ||
if isinstance(scales, (int, float)): | ||
scale.apply_to_frames(cursor.frames, scale=scales) | ||
else: | ||
cursor.frames = scale.apply_to_frames_MS(cursor.frames, scales=scales) | ||
elif args.size: | ||
sizes = eval(args.size) | ||
if isinstance(sizes, (int, float)): | ||
scale.apply_to_frames(cursor.frames, size=sizes) | ||
else: | ||
cursor.frames = scale.apply_to_frames_MS(cursor.frames, sizes=sizes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not duplicate code.
cursor.hotspot = (int(hx * scale), int(hy * scale)) | ||
|
||
|
||
def apply_to_frames_MS(frames: List[CursorFrame], *, scales: List[float] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is _MS
? Use a more sensible name.
if scales is not None: | ||
for scale in scales: | ||
frames_s = [frame.clone() for frame in frames] | ||
apply_to_frames(frames_s, scale=scale) | ||
frames_MS.extend(frames_s) | ||
else: | ||
for size in sizes: | ||
frames_s = [frame.clone() for frame in frames] | ||
apply_to_frames(frames_s, size=size) | ||
frames_MS.extend(frames_s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be one function? It's basically two separate functions.
for scale in scales: | ||
frames_s = [frame.clone() for frame in frames] | ||
apply_to_frames(frames_s, scale=scale) | ||
frames_MS.extend(frames_s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you concatenating frames of different sizes? This is wrong. A frame contains multiple images of different sizes. When scaling an animated cursor, you keep the same number of frames, but each frame will have more images.
Make
--scale
argument support input of multiple scales.--scale 0.25
resize the cursor to 1/4 of its original size.--scale "[0.125,0.25,0.5]"
resize the cursor to multiple scales and put them into one cursor file.Add
--size
argument to support specify multiple output size.--size 32
resize the cursor to 32px.--size "[32,48,64]"
resize the cursor to multiple sizes and put them into one cursor file.