Jack000/Expose

Photos not saving

SteveEdson opened this issue · 20 comments

This looks great, can't wait to integrate it with my Jekyll site.

I'm having an issue however, I only have 1 image, but it is not being saved out. Here is the output:

$ expose
Scanning directories...
Populating nav...
Reading files.
Building HTML.
Starting encode
steve


 $ tree .
.
├── 2015
│   └── shoot
│       └── steve.jpg
└── _site
    ├── 2015
    │   └── shoot
    │       ├── index.html
    │       └── steve
    ├── cookie.js
    ├── global.css
    ├── global.js
    ├── img
    │   ├── camera.png
    │   ├── camera_mask.png
    │   ├── close.png
    │   ├── comment.png
    │   ├── comment_mask.png
    │   ├── download.png
    │   ├── download_mask.png
    │   ├── facebook.png
    │   ├── facebook_mask.png
    │   ├── hackernews.png
    │   ├── hackernews_mask.png
    │   ├── heart.png
    │   ├── heart_mask.png
    │   ├── monitor.png
    │   ├── monitor_mask.png
    │   ├── next.png
    │   ├── pinterest.png
    │   ├── pinterest_mask.png
    │   ├── prev.png
    │   ├── reddit.png
    │   ├── reddit_mask.png
    │   ├── text.png
    │   ├── text_mask.png
    │   ├── twitter.png
    │   └── twitter_mask.png
    ├── index.html
    └── json.js

7 directories, 32 files

Same problem here (with some additional error message)

root@terminal40748:~/Expose/photos# uname -a
Linux terminal40748 2.6.32-042stab104.1 #1 SMP Thu Jan 29 12:58:41 MSK 2015 x86_64 x86_64 x86_64 GNU/Linux

root@terminal40748:~/Expose/photos# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"

root@terminal40748:~/Expose/photos# ../expose.sh
Scanning directories../expose.sh: line 218: /dev/fd/62: No such file or directory

Populating nav
Reading files
Building HTML
Starting encode
root@terminal40748:~/Expose/photos# tree .
.
|-- _site
|   |-- cookie.js
|   |-- global.css
|   |-- global.js
|   |-- img
|   |   |-- camera.png
|   |   |-- camera_mask.png
|   |   |-- close.png
|   |   |-- comment.png
|   |   |-- comment_mask.png
|   |   |-- download.png
|   |   |-- download_mask.png
|   |   |-- facebook.png
|   |   |-- facebook_mask.png
|   |   |-- hackernews.png
|   |   |-- hackernews_mask.png
|   |   |-- heart.png
|   |   |-- heart_mask.png
|   |   |-- monitor.png
|   |   |-- monitor_mask.png
|   |   |-- next.png
|   |   |-- pinterest.png
|   |   |-- pinterest_mask.png
|   |   |-- prev.png
|   |   |-- reddit.png
|   |   |-- reddit_mask.png
|   |   |-- text.png
|   |   |-- text_mask.png
|   |   |-- twitter.png
|   |   `-- twitter_mask.png
|   |-- index.html
|   `-- json.js
|-- cental_park\ -\ 1.jpg
|-- cental_park\ -\ 2.jpg
|-- cental_park\ -\ 3.jpg
|-- cental_park\ -\ 4.jpg
|-- cental_park\ -\ 5.jpg
|-- cental_park\ -\ 6.jpg
`-- cental_park\ -\ 7.jpg

2 directories, 37 files

SteveEdson: I'm guessing it's either imagemagick or the file itself. The image wouldn't be generated if the convert command fails. Do you get anything if you run this?

 convert ./2015/shoot/steve.jpg -resize 100x100 -quality 92 +profile '*' ./test.jpg

qmaxquique: I think your problem is different, because it fails at the scanning directories stage. The script uses find to get a list of directories from your cwd. What do you get if you run this?

 find . -type d ! -path ".*/_*" | sort

@Jack000 converting the file manually works without any issues :/

For some reason, it's saving the photo as an empty directory, rather than a photo

yeah that's what I'd expect. It creates a directory and saves each resolution in the directory.

my next guess is that it probably misidentified the image type. What do you get if you run this?

 identify -format "%m" ./2015/shoot/steve.jpg

Here is the output. The image is just my

$ identify -format "%m" ./2015/shoot/steve.jpg
JPEG%

The image is just my avatar.

Thanks

is that % in the output? that'd be the problem, but I don't have any idea why it would do that... will investigate

Thanks.

Also worth noting that the % is in a slightly different colour to JPEG on my terminal.

Also, here is the output using exiftool:

ExifTool Version Number         : 10.01
File Name                       : steve.jpeg
Directory                       : 2015/shoot
File Size                       : 41 kB
File Modification Date/Time     : 2015:10:14 11:50:40+01:00
File Access Date/Time           : 2015:10:14 12:31:28+01:00
File Inode Change Date/Time     : 2015:10:14 11:50:52+01:00
File Permissions                : rw-r-----
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Comment                         : CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 90.
Image Width                     : 460
Image Height                    : 460
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 460x460
Megapixels                      : 0.212

It's nothing to do with the actual image format / encoding:

$ identify -format "%n" ./2015/shoot/steve.jpeg
1%

Where

%n number of images in current image sequence

All values seem to have a % at the end.

weird, I guess output from the identify command isn't always reliable. This commit should address your issue, if the % was indeed the problem: bdb5a9c

zeeZ commented

What's your ImageMagick/Identify version?
Which shell are you using?
That's super weird and not something I've come across in ImageMagick documentation.

I'm using oh-my-zsh (zsh)

Version: ImageMagick 6.9.2-4 Q16 x86_64 2015-10-11 http://www.imagemagick.org

Interesting, changing the command to:

identify -format "%m\n" ./2015/shoot/steve.jpeg

with the new line character, it removes the trailing %

ah, zsh. That's probably the issue. I originally just wrote this for myself and there are some bash-specific things in there. It's pretty hard to make a script universally portable unfortunately, without resorting to perl or something.

Are you sure you're using zsh though? On zsh you'd get errors at the very beginning, from a reference to BASH_SOURCE

Yeah definitely

$ scriptdir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
$ echo $scriptdir
/Users/steve

Also:

$ echo $0
-zsh

hehe, I think I've overlooked the extremely obvious. I assumed that the source images would be from a camera so it only downscales. Added a patch to upscale small images to the minimum resolution: b486b8d

Bingo, problem solved.

Thanks!