! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Patch to add support for saving screen shot as jpeg file
Status:
RESOLVED: MOVED
Severity:
enhancement
Product:
Xfce4-screenshooter
Component:
General

Comments

Description Gert Wollny 2015-08-08 11:47:54 CEST
Hello, 

the attached patch add the option -j/--jpeg to enable saving as jpeg file. 

With this option given: 
- the image will be saved to jpeg file with the default jpeg options used in the gdk_save_image function. 

- in the file dialog the file name is presented with the 'jpg' extension. If this extension is changed to anything else, a png file will be saved. 

Independently. if in the file dialog the extension is set to 'jpg', the image is also saved as jpeg file. 

best regards, 
Gert
Comment 1 Gert Wollny 2015-08-08 11:49:01 CEST
Created attachment 6405 
Patch against v1.8.2, tested on Gentoo Linux.
Comment 2 Gert Wollny 2015-08-08 11:52:49 CEST
Created attachment 6406 
Patch against v1.8.2, tested on Gentoo Linux.

Cleans the superfluous "Only in ... " lines
Comment 3 Landry Breuil editbugs 2015-11-01 10:16:14 CET
Instead of flying all around a new boolean option (what if next, someone wants to add a 'save as tiff' option ?) maybe we should un-hardcode png from the path when saving and just use the extension provided by the user in the full path ?
Comment 4 Gert Wollny 2015-11-01 12:13:51 CET
Well, my incentive for providing saving to jpeg was that because it uses lossy compression and therefore the files are way smaller. The command line option is there so one can change the default file type that is proposed in the save dialogue (i.e. I now use it in the command that is bound to the screenshot).  

Switching here from a boolean option to a string option that contains the suffix should be possible though and generalize this feature. I will see if I can provide a different patch.
Comment 5 Landry Breuil editbugs 2015-11-01 12:18:47 CET
I totally get the incentive, but from my experience lossless png can already be compressed/optimized, and jpeg is better suited for actual camera pictures. But fine, why not :)

Note that even if the screenshot is taken as a png, uploading it to imgur will automatically degrade it and compress it to jpeg too..
Comment 6 Gert Wollny 2015-11-01 13:58:45 CET
Created attachment 6516 
Patch against v1.8.2 to enable more image file types, tested on Gentoo Linux.

This patch replaces the uoption --jpeg/-j proposed in the earlier patch by --filetype/-t and enables the user to set the output image type to any type that is supported by gdk-pixbuf.
Comment 7 Gert Wollny 2015-11-01 14:06:02 CET
Well, on of my uses for screen shots is to create background images from full-screen views of photos, this is easier that using gimp to cut out an image of the right size :)

Back to the latest patch: I wanted to add output of a list of supported formats, but  gdk_pixbuf_get_formats () reports more than the library can actually handle (e.g. svg, but later is says that the version of pixbuf doesn't support writing bitmaps to svg), so I left this out. 

I have tried it with jpeg, png, and tiff, and it worked. One thing one might consider is, that if the extension given in the dialogue is not supported, then the option to retry saving would probably be nice.
Comment 8 Landry Breuil editbugs 2015-11-01 14:26:59 CET
Nice, i'll try it.... but im still not comfortable with adding a new param for each and every function call, would be so much nicer to store the extension directly in the filename/save_uri/save_file where possible :)

Something like 'if provided title has an extension, use it to figure out the filetype the user wants (eventually munge the name with timestamps/pattern if needed) otherwise default to .png'
Comment 9 Gert Wollny 2015-11-01 15:44:34 CET
I'm not quite sure what you mean with 'provided title', AFAIK so far you only offer a parameter that sets the output directory, and the (proposed) file name is created automatically. If you want to replace this parameter so that it also can accept a full path with a place holder for the date and file extension, fine. 

My idea was that the command line parameter sets the proposed file type, e.g. when you do a screen shot with a shortcut key and want to set the file type to something that is not the default (=png) without having to edit it each time in the save dialogue, and I wanted to achieve this by changing your code as little 
as possible. 

In any case I actually think that most people don't call the screenshot program from the command line, and therefore, don't care about them ;)
Comment 10 Landry Breuil editbugs 2015-11-12 23:22:08 CET
Sorry for being not really reactive on this, i have a broken internet connection those days; Also, this is not *my code*, i happen to apply patches now and then but most of it was done by jerome :)

That said, now i understand better the usecase, so yes being able to pass the parameter around would be okay for this, and still allow an user using the GUI to set the filetype, based on the extension he'd use for the filename he types when saving the file.

And i do call xfce4-screenshooter on the cli, but most of the times without arguments :)
Comment 11 Gert Wollny 2015-11-12 23:43:39 CET
Don't worry, from my side there is no rush - on Gentoo can easily run the patched version. I only thought that since I find it useful, maybe others will do so too, so why not send the patch upstream :)
Comment 12 Git Bot editbugs 2020-05-24 23:56:29 CEST
-- GitLab Migration Automatic Message --

This bug has been migrated to xfce.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.xfce.org/apps/xfce4-screenshooter/-/issues/6.

Please create an account or use an existing account on one of our supported OAuth providers. 

If you want to fork to submit patches and merge requests please continue reading here: https://docs.xfce.org/contribute/dev/git/start#gitlab_forks_and_merge_requests

Also feel free to reach out to us on the mailing list https://mail.xfce.org/mailman/listinfo/xfce4-dev

Bug #12122

Reported by:
Gert Wollny
Reported on: 2015-08-08
Last modified on: 2020-05-24

People

Assignee:
Jérôme Guelfucci
CC List:
1 user

Version

Version:
unspecified

Attachments

Additional information