This would be a really sweet QOL feature. A feature that automagically detects the upscaling and converts back to original scale
I have a script that does exactly that. Iβll update this post later with it.
UPDATE:
Hereβs the script, I never posted it anywhere because I wasnβt sure its use case is very common. Right now it only works on a single cel (one layer, one frame) and requires a clean image - JPGs wonβt work, trust me, I tried.
if app.activeSprite == nil then return end
-- For simplicity, for now just take into account the image from the active cel
local image = app.activeCel.image
-- First, go throught each row - look for the narrowest part that doesn't change color
local narrowest = image.width
for y = 0, image.height - 1 do
local lastColor = image:getPixel(0, y)
local currentWidth = 1
for x = 1, image.width - 1 do
local currentColor = image:getPixel(x, y)
if currentColor == lastColor then
currentWidth = currentWidth + 1
else
if currentWidth < narrowest then narrowest = currentWidth end
currentWidth = 1
end
lastColor = currentColor
end
end
-- Second, go throught each column - look for the shortest part that doesn't change color
local shortest = image.height
for x = 1, image.width - 1, narrowest do
local lastColor = image:getPixel(x, 0)
local currentHeight = 1
for y = 0, image.height - 1 do
local currentColor = image:getPixel(x, y)
if currentColor == lastColor then
currentHeight = currentHeight + 1
else
if currentHeight < shortest then shortest = currentHeight end
lastColor = currentColor
currentHeight = 1
end
end
end
app.command.SpriteSize {
ui = false,
scaleX = 1.0 / narrowest,
scaleY = 1.0 / shortest,
method = "nearest"
}
3 Likes
I attempted to develop an algorithm that could descale a JPEG but thatβs a complete nightmare.
1 Like
Thank you, this is so clever, and it works brilliantly
2 Likes