DougBeney / Jekyll-Bliss

The Answer to Slow Compiles Time In Jekyll
5 stars 0 forks source link

Image corrupted when building #4

Open ErikBjare opened 4 years ago

ErikBjare commented 4 years ago

I have a largeish image (a screenshot) that jekyll-bliss somehow fails to copy correctly into the _site directory.

It even causes feh to refuse to open the file at all:

$ feh _site/img/screenshot-v0.9.3-activity.png                                                                                                                                              
libpng error: Read Error                                                                                                                                                                      
feh WARNING: _site/img/screenshot-v0.9.3-activity.png - No Imlib2 loader for that file format                                                                                                 
feh: No loadable images specified.                                                                                                                                                            
See 'feh --help' or 'man feh' for detailed usage information

Edit: I notice now that this happens for all png files (probably not just png's) larger than 128K, which then get truncated to 128K.

If I cd _build && bundle exec jekyll build the file builds correctly (into _site/_build).

-rw-r--r-- 1 erb users 234K Jul 16 14:17 img/screenshot-v0.9.3-activity.png
-rw-r--r-- 1 erb users 234K Aug  1 10:21 _build/img/screenshot-v0.9.3-activity.png
-rw-r--r-- 1 erb users 234K Aug  1 10:21 _build/_site/img/screenshot-v0.9.3-activity.png
-rw-r--r-- 1 erb users 128K Aug  1 10:21 _site/img/screenshot-v0.9.3-activity.png

The source image:

image

The resulting image (yes, half the image is missing):

image

ErikBjare commented 4 years ago

I managed to work around the issue by reducing my pngs to 8-bit color and running optipng on them, to get the size down.

Still weird that it happens, looked through the code of jekyll-bliss don't understand what could possibly cause it.

DougBeney commented 4 years ago

It's been a while since I messed with the code, but we can probably start with this line:

See if you can reproduce this issue by creating a Node script and running:

var fs = require('fs')

fs.createReadStream( your_png_filename ).pipe(fs.createWriteStream( your_output_png_location_filename ))
ErikBjare commented 4 years ago

I found that line but it looked really innocent to me. Especially since it copies the image to the build folder (I think), where the image is intact. The file doesn't get truncated until it's moved to the _site folder.

I ran the snippet, and it works fine.