Subject: bug#18632: 24.3.94; image-dired fail when `image-dired-dir' doesn't exist

From: Stefan Kangas <[email-masked]>
Date: Fri, 30 Aug 2019 00:32:52 +0200

Thierry Volpiatto <[email-masked]> writes:

>> If `image-dired-dir' doesn't exists, image-dired fail with
>> something like "could not resize image" with no indications on what is happening.
>> IOW image-dired should create its directory when this one doesn't
>> exists, or at least send a helpful message to notify user he have first
>> to create manually this directory.
>
> diff --git a/lisp/image-dired.el b/lisp/image-dired.el
> index 114deab..01f88c2 100644
> --- a/lisp/image-dired.el
> +++ b/lisp/image-dired.el
> @@ -1800,7 +1800,8 @@ should feel snappy enough.
>
>  If optional argument ORIGINAL-SIZE is non-nil, display image in its
>  original size."
> -  (let ((new-file (expand-file-name image-dired-temp-image-file))
> +  (let ((new-file (expand-file-name image-dired-temp-image-file
> +                                    (image-dired-dir)))
>          width height command ret
>          (image-type 'jpeg))
>      (setq file (expand-file-name file))

I can reproduce this on current master.  The problem happens when the
user removes the image-dired-dir directory (normally
~/.emacs.d/image-dired).

Steps to reproduce:

0. emacs -Q
1. C-x C-f ~/my-image-dir
2. (in shell) rm -rf ~/.emacs.d/image-dired/  # value of (image-dired-dir)
3. (in emacs): RET

Now I see the error message "Unable to resize".

However, I think the above patch is only part of the solution.  After
applying it, I can indeed open an image successfully.  But I'm now
seeing a different problem: After opening an image (step 3 above), all
the thumbnails are suddenly missing from the *image-dired* buffer.

I subjectively think that the original error is less severe than the
new one.  Without the fix, at least the images stay as they are in the
*image-dired* buffer.

If anyone disagrees, they could easily install the above patch on
master and we would arguably be no worse off than we are now.  But we
would still need to fix the second problem.

Thanks,
Stefan Kangas