How to correctly save an image.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
cristoferfb
Prole
Posts: 16
Joined: Wed May 15, 2019 12:41 am
Location: Valparaiso, Chile.

How to correctly save an image.

Post by cristoferfb »

Hi, I want to experiment with an image editor, so I currently do a simple thing:

1.- Open a image
2.- Draw it to canvas (with the same size than the original image)
3.- Save the canvas as image
4.- (waiting an eternity)
5.- A png of 50 mb was created (LOL)

¿What is the correct way of create images?
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to correctly save an image.

Post by zorg »

Löve can only save png files.

If you want to export to some other format, you need to write an encoder or use a library.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Nelvin
Party member
Posts: 124
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

Re: How to correctly save an image.

Post by Nelvin »

TGA works too ... I just noticed this a very few months ago and now use it during development as both, writing (from within my asset handling tools) and loading (when running the game) is much much faster on my system.

It turned probably around >= 5 seconds of startup time into a blink which doesn't sound like that much of a change but to me, in my general workflow/coding habits it's a world of a difference.

You of course need a SSD for this to help, but I guess most devs use SSDs now.

That said, a 50mb png sounds like a pretty big image so if you write it as TGA the file size may be huge and if your main concern is different popular file formats you'll have to do some more work I guess.
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to correctly save an image.

Post by zorg »

Nelvin wrote: Mon Jun 01, 2020 8:53 am ...
That's nice and all but i'm pretty sure the question was about saving images with specific formats, not what types does löve support loading. :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Nelvin
Party member
Posts: 124
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

Re: How to correctly save an image.

Post by Nelvin »

zorg wrote: Mon Jun 01, 2020 10:25 am
Nelvin wrote: Mon Jun 01, 2020 8:53 am ...
That's nice and all but i'm pretty sure the question was about saving images with specific formats, not what types does löve support loading. :3
That's why I wrote TGA and in addition some other info why it may be at least a easy usable additional format wrt to the time required to save the image.
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to correctly save an image.

Post by zorg »

I guess i just understood your post as löve supports loading TGA files, not that it supports saving them.
Edit: According to the wiki, saving tga might have been added, wasn't aware of that. :v
Last edited by zorg on Tue Jun 02, 2020 8:55 am, edited 1 time in total.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
cristoferfb
Prole
Posts: 16
Joined: Wed May 15, 2019 12:41 am
Location: Valparaiso, Chile.

Re: How to correctly save an image.

Post by cristoferfb »

Ok Love2d only can output png files (the tga format is not useful for me) ¿How to get a more reasonable size for the final archive? I check the original photo I used for this test and apparently modern phones take 4k photos as the default behaviour (2k20 lol), so I create a 720p canvas and apply a downscale to the image draw job, now encode the canvas to a PNG file give my a 10 mb file, that is better but ¿I can do something more for get a more lightweight image?
Nelvin
Party member
Posts: 124
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

Re: How to correctly save an image.

Post by Nelvin »

zorg wrote: Mon Jun 01, 2020 3:14 pm I guess i just understood your post as löve supports loading TGA files, not that it supports saving them.
Edit: According to the wiki, saving tga might have been added, wasn't aware of that. :v
Yeah that's what I meant - and primarily because the original poster also wondered about the long time saving a big png requires. TGA is not the most common format, but even if it's just to speedup development before adding whatever external library for additonal formats, it may be a valid alternative. But given the lastest post it seems like it's not.

I have no idea when it was added - I just by accident stumbled over it because my texture packer became to slow for my taste and I wanted to know if there's a way to disable png compression :)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 42 guests