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

JPG image optimization not working #16

Closed
jeffwhelpley opened this issue Feb 15, 2013 · 26 comments
Closed

JPG image optimization not working #16

jeffwhelpley opened this issue Feb 15, 2013 · 26 comments

Comments

@jeffwhelpley
Copy link

When I use this:

            dist: {
                options: {
                    optimizationLevel: 3
                },
                files: {
                    '../dist/img': ['../images/**/*.*']
                }
            }

It won't copy my jpg images and if I specify an jpg like this:

            dist: {
                options: {
                    optimizationLevel: 3
                },
                files: {
                    '../dist/img/email.jpg': ['../images/email.jpg*']
                }
            }

I get the following error:

Fatal error: ENOENT, no such file or directory 'c:\proj\dist\img\email.jpg'

@oldskool73
Copy link

I'm getting the same error with a default 'yo webapp' build:

imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '*.{png,jpg,jpeg}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
Running "imagemin:dist" (imagemin) task
Error
Fatal error: ENOENT, no such file or directory 'dist/images/test.png'

this is happening for both jpg AND png test files for me on OSX.

@tolusonaike
Copy link

I am getting the same issue here with the default gruntfile created with "yo webapp" (1.0)

@omasback
Copy link

yeah im getting exact same thing as oldskool. I ran yo webapp then i ran grunt build. It built fine. then i put one png in the app/images folder and ran the build again and it failed.

Fatal error: ENOENT, no such file or directory 'dist/images/ringlogo-yellow.png'

Im running osx 10.6

@dennishn
Copy link

I am facing the same issue aswell, allthough if i specify only png files it works fine:

imagemin: {
    dist: {
        files: [{
            expand: true,
            cwd: 'images',
            src: '**/*.png',
            dest: '<%= yeoman.dist %>/images'
        }]
    }
}

Everything is okay, files gets copied and minified.

But:

imagemin: {
    dist: {
        files: [{
            expand: true,
            cwd: 'images',
            src: '**/*.jpg',
            dest: '<%= yeoman.dist %>/images'
        }]
    }
}

Results in a

Fatal error: ENOENT, no such file or directory 'dist/images/test.jpg'

If i test the grunt-contrib-imagemin from within the node_modules of my webapp (and include a jpg files to test on ) :

\webapp\node_modules\grunt-contrib-imagemin\grunt imagemin:dist --verbose

It doesnt work either. It does however work with png files here aswell.

I'm using Windows 7

@rob-bar
Copy link

rob-bar commented Feb 26, 2013

I'm running on mac and have the same issue with png files.
So this is not an os system issue.
Can someone help us
default yo webapp config

@dennishn
Copy link

I fixed it on Windows by doing two things:

  1. Downloading and updating my jpegtran.exe file following the steps here:
    https://github.com/yeoman/node-jpegtran-bin
  2. Copying jpeg62.dll from the libjpeg-turbo folder extracted earlier to the jpegtran-bin folder in the imagemin node_modules folder..
    In my case from:
    C:\libjpeg-turbo64\bin
    To:
    ..\webapp\node_modules\grunt-contrib-imagemin\node_modules\jpegtran-bin\vendor\win64

After that the imagemin task runs fine and minifies jpg files aswell.

@jahvi
Copy link

jahvi commented Feb 27, 2013

The suggestion from @dennishn worked fine, I wish it gets fixed soon though

@sindresorhus
Copy link
Member

@dennishn can you open a PR on node-jpegtran-bin with that fix?

@dennishn
Copy link

@sindresorhus I can, but i have no clue which files people on other OS's need.

@hansek
Copy link

hansek commented Mar 4, 2013

@dennishn Thx, your solution works also for Windows 7 32-bit.

Only is needed to download 32-bit version of libjpeg-turbo (libjpeg-turbo-1.2.90-vc.exe) and copy DLL to ..\grunt-contrib-imagemin\node_modules\jpegtran-bin\vendor\win32

@sindresorhus
Copy link
Member

I've updated the Windows binaries and added the dll file.

Could anyone test if it's working?

Just replace the one living in the imagemin node_modules folder with master https://github.com/yeoman/node-jpegtran-bin

@jahvi
Copy link

jahvi commented Mar 6, 2013

@sindresorhus I can confirm it's working now on Win7 64bits

@sindresorhus
Copy link
Member

New version of jpegtran-bin published. Try reinstalling this task and let me know how it works for you now:

npm uninstall grunt-contrib-imagemin && npm install grunt-contrib-imagemin

@tolusonaike
Copy link

Works on OSX! Doesnt seem to copy subfolders though. Is this unrelated?

[ OSX 10.8.2, node v0.8.22, npm 1.2.11 ]

@sindresorhus
Copy link
Member

Doesnt seem to copy subfolders though. Is this unrelated?

Yes, see "Building the files object dynamically" in the docs: https://github.com/gruntjs/grunt/wiki/Configuring-tasks

@zealton
Copy link

zealton commented Aug 23, 2013

I still can't make it work although I tried the above ways.
[npm 1.3.7 ; node v0.11.6pre ; OS 10.8.4 ]

@kitsguru
Copy link

I am having this same issue on Win 7 64 bit sp1
I have followed the above instructions and uninstalled and re-installed imagemin and replaced jpegtran per @dennishn
Setup:
npm 1.3.8
yo 1.0
grunt 0.4.1
imagemin 0.3.0

Running grunt -v I get the following output after several files are processed ok then: snippet just before things go south :(

Reading ../www/src/css/images/home1.png...OK
?PNG
→

IHDR  ?   ♣☺♥   '??(   ♦gAMA  ??♂?a♣   ☺sRGB ??∟?   ♠PLTE   ?1m?j   ☺tRNS @??f
  IDAT8?c?a↑? Ab?z]☻??◄
xFr???♫ ?       ☺§?cM?    IEND?B`??PNG
→

IHDR  ?   ♣☺♥   '??(   ♦gAMA  ??♂?a♣   ☺sRGB ??∟?   ♠PLTE   ??????   ☺tRNS @??f
   IDAT8?c?a↑? Ab?z]☻??◄
xFr???♫ ?       ☺§?cM?    IEND?B`??PNG
→

IHDR   ►  ♥   (-☼S   ♦gAMA  ??♂?a♣   ☺sRGB ??∟?  ☺?PLTE   ?6*o71¶‼‼?.,?6,?>,?+-?
*,?0,?bC2+  ∟?l7'?c?⌂Syx{QOM ▲▼uty??pJGB????@"?tRL<`_c??w???XKB2!▲↔?}↨?g:??y??V?
^?S???u|qSj>4?k↑??\??w??s?H!?~↨??|??w??h?`??T??,?7,?1?*,?*,?.,?+,?.,?,,|+,?+,o&+
?)+?3,?5,?))?'.?<.?=(?50?J&?G@?uA?F*?zS?:+?|C?N?M/?TD?H+?[?]?=,??n?X???/3???U?@?
=(?xR??c??r,??c??l?E&?Z:??s?-?H,?*??d??d?\??k??x?V?a??+?e?k??N?l?=#??w????i??s??
??zwA.?G,?h?wTz???G'?E,??z??s?[???M.?J(??o??t?l◄????G3??↓???h???a???f6?Y?f??e???
`??♦???Q?;   6tRNS ?(☺?UR??☻↑~S?♀♣X?↑???Pg%??A♀B??????k⌂??↓%%\‼??????d   ?IDAT↑?
c` ♠?z?;??XYr?C?↕☺>nN♫v??,? ??Zzd???????9+H@??0'??????↑↑4*??SÂ?[?B|=↑↓↑?k*♂"↕→?[
????Zt?J???→'vMo????g??∟???1cZ⌂?*H@W=?"?oR???s??q♥♣dd‼-?K'?O?3[??↓(  *↓?]^?;?D??
RA???:Sy?_?D???5§P=(&♀e  ?u1?\??    IEND?B`??PNG
→

IHDR       ♥   D???   ♦gAMA  ??♂?a♣   ☺sRGB ??∟?  ☻?PLTE   g)*?R#A=9r**??w$ ∟??_
5y*+Oam2&?d ?2,mK7??n3.*???$ DA?c?~e,($%!↔?]A9*?s↑?c?*,?*,?*,?*,?1,?4,?;,?5*?>+?
?s?????????l+*????n????Â??V?`???????N;eZA&"▲\SA?a!n3'?k▲~|{?d??éa??U?iO?v??W????
?u↓`/+?Z ??IFC@??????6(?v↑?F"?cy8'?v↑?d∟??f?`´~??t?y??U??Po`@?v↨?v↨?L!?X"?i▼?x1?
u↓?s→?h?v↨?Q x9%?v↑???d?>,?B+?E+?-,??x?5?1,?:,????a?5,?9,??q??n??k??~?d?R?*,?J+Z
((?6,?@,??`??q?d?*,~*,?*,?*,?*,??uz*+??{??sv*+p*+?Z?I*?Z?c?N*??c?[?d?/,?*,??z?{i
??g?5??d?S?G+?s??t?L*?Y?:,U]?\?\u??}*,?*,?2,???d?8?b?T?@*???VD??qh)*?P???f?rW?a?
]?2,?P)?:???D)?7-dmx????{?u`>?Y8l;.????O?K?*,?_?:?OH?E?/+?⌂P?J?|V?DE?k?*,L??5?k?
⌂G?V?;?gT}?3?S2?I7?]?nD?e???⌂???MIM??Sd)*?u?Z?bA??Q?==pxyUx???a?????z????E%r20i?
?mvz~???E?|B?[=b1+?v7#??☼   ftRNS /♀I2r♂?☺6???s♠?▲6?7§HY?G6w??I?8A?p??<?+?????)w
????t????????u?▼??h8?H-|???????G??↔?&o??2?T???¶"?  ☻xIDAT8?c`?#??c♦☻▬ ?♦☺♫t?X?//
6o??????X???,?&?????§(??????&y↓¶y???q??;???6?hk?☻☻9&d♣??5?N?};?uE[UKK6↑?"?'%?∟=q
b??@???S??@☺.▼%?}?de???[???,**???-*R?Y?◄↓]?r??=3?♥?k????↑f?⌂@??%;v?W^8♂???p?|%??
7?????3g?Q♀????♦???♀§?☼?}j???9???????♀?l▬¶d?W♠*?p?9?^VVVZZ?v?♀???}?@??H?♣?????-↔
$???i??@?♣♂&N??o?]#>?+????9@p???♣‼w??h???%`??_ZRr:gzgyy?6?{}?w-z?f???H
J?Kg?Y7???`???☼??Z???'?)?0♣??9%?????o(?^?p!???↔o?"
W???♫T?;k?????☼♫,[v?0????9??kn????3?b????♫}l?↕♫W?Y????s@
?
?∟???@#?$AyA???m?→?
?>~9?1??0U?♂
?♂♂?wB§\?6aBP?↑<=?jo *(?♀R0)?b??♦[Iq?t- ??[??@??D 5Q??Ze?U ????m4?♦♣=BBA
lL?8??,-CKwf?`O16<?M?Y???,♂ ^S"6???m    IEND?B`?Deleting ../www/src/css/images/a
rrowsub_o.png...ERROR
Warning: Cannot delete files outside the current working directory. Use --force
to continue.

Aborted due to warnings.

Running grunt --force seems to work fine

@twiz-
Copy link

twiz- commented Oct 23, 2013

👍 for @sindresorhus reinstallation fix

@danielvdende
Copy link

Having the same problem here on OS X, tried proposed solution by @dennishn. Sadly didn't work. Also reinstalled grunt-contrib-imagemin, but did not help. Is there a workaround/fix for OS X yet?

@Meandmybadself
Copy link

For those running into this issue, I've found a solve on OSX by not relying upon imagemin to copy the files to a destination location. Instead:

  • Copy the images to the destination folder using grunt-contrib-copy
  • Run imagemin against the images in the dist folder.

@cesarandreu
Copy link

I tried upgrading to 0.5.0 but got this error. Not getting this error with 0.3.0.

I'm on OS X 10.9.1, using node v0.10.24.

@adam-marshall
Copy link

Same problem here on Win7 64. Tried everything in the thread so far. Now taking the same approach as @Meandmybadself

@wangshijun
Copy link

Same problem here on Mac OSX. Tried everything in the thread so far. Now taking the same approach as @Meandmybadself

@rileytg
Copy link

rileytg commented Mar 27, 2014

Having this issues also on OSX

@kevva
Copy link
Member

kevva commented Mar 27, 2014

Use 0.6.0-pre.

@Furqankhanzada
Copy link

New version of jpegtran-bin published. Try reinstalling this task and let me know how it works for you now:
npm uninstall grunt-contrib-imagemin && npm install grunt-contrib-imagemin

@sindresorhus thanks, its working for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests