Skip to content
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

Cannot save images with capital letter extensions #51

Closed
cykerway opened this issue Jul 29, 2011 · 4 comments
Closed

Cannot save images with capital letter extensions #51

cykerway opened this issue Jul 29, 2011 · 4 comments
Assignees
Labels

Comments

@cykerway
Copy link

For example,

feh DSCxxxxx.JPG

can view the image. But when type 's' to save it, the console gives:

feh WARNING: Can't save image feh_xxxxxx_xxxxxx_DSCxxxxx.JPG: No such file or directory

@livibetter
Copy link
Contributor

The problem looks like in this:

void
gib_imlib_save_image_with_error_return(Imlib_Image im, char *file,
                                       Imlib_Load_Error * error_return)
{
   char *tmp;

   imlib_context_set_image(im);
   tmp = strrchr(file, '.');
   if (tmp)
      imlib_image_set_format(tmp + 1);
   imlib_save_image_with_error_return(file, error_return);
}

The listed formats are all lower cases in imlib, I didn't check if imlibs would do anything to format string, I guess it's just do a simple compare, therefore "JPG" still != "jpg".

Here is a quick fix:

diff --git a/src/slideshow.c b/src/slideshow.c
index 6d39d2c..fb1fcc3 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -472,7 +472,8 @@ void slideshow_save_image(winwidget win)
    if (!opt.quiet)
        printf("saving image to filename '%s'\n", tmpname);

-   gib_imlib_save_image_with_error_return(win->im, tmpname, &err);
+   imlib_context_set_image(win->im);
+   imlib_save_image_with_error_return(tmpname, &err);
    if (err)
        im_weprintf(win, "Can't save image %s:", tmpname);

According to the imlib doc,

EAPI void imlib_image_set_format ( const char * format )

Sets the format of the current image. This is used for when you wish to save an image in a different format that it was loaded in, or if the image currently has no file format associated with it.

I believe it has format associated already and it's same format as the original file, therefore those two lines have enough information for imlib to save image. I tested with JPG and PNG, I did get the saved files.

@cykerway
Copy link
Author

cykerway commented Aug 1, 2011

Tested and it works. Great. But are you sure that the format is always associated? If so, I think the function gib_imlib_save_image_with_error_return can be trimmed into 2 lines... Maybe the author can merge this into the master branch. Close it.

@cykerway cykerway closed this as completed Aug 1, 2011
@livibetter
Copy link
Contributor

No, I am not sure. That's why I said "I believe." ;)

derf will review this. Maybe it's better to get to fix this (gib_imlib_save_image_with_error_return()) in giblib (but I don't feel it's still active), because there's the reason to use giblib, though you can directly call imlib to do the job.

@derf derf reopened this Aug 7, 2011
@ghost ghost assigned derf Aug 7, 2011
@derf
Copy link
Owner

derf commented Aug 10, 2011

I'll merge the patch for now.

It should be fixed in giblib, but it was created by the same author as feh, so it's unmaintained right now. And I don't think that particular bugfix is relevant for the two or three other existing programs using giblib.

Yet again, thanks for the patch :)

@derf derf closed this as completed in ae1de0d Aug 10, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants