#44 Windows binaries using wrong slash in output filename

open
devel (22)
5
2012-08-22
2012-01-07
Anonymous
No

Problem: The Windows binaries sometimes use a forward slash instead of a back slash in the output filename, which generates an error, but pngcrush writes a very large PNG file to the output filename anyway, which is annoying behavior, because it actually makes files that are larger than the original.

Expected outcome: Pngcrush should use only backslashes in the filename on Windows platforms, and it should not write larger files than the original if a filesystem error occurs.

Terminal output: (notice the forward slash in the error message "Could not open output file")

C:\Users\admin\folder>C:\Users\admin\pngcrush.exe -d "C:\ Users\admin\folder_crush" -bit_depth 1 -plte_len 1 -brute -w 32 -
c 0 "C:\Users\admin\folder\image0009.png"

pngcrush 1.7.15
Portions copyright (C) 2005 Greg Roelofs
This is a free, open-source program. Permission is irrevocably
granted to everyone to use this version of pngcrush without
payment of any fee.
Executable name is pngcrush
It was built with libpng version 1.5.2rc02, and is
running with libpng version 1.5.2rc02 - March 22, 2011

| Copyright (C) 1998-2004, 2006-2011 Glenn Randers-Pehrson,
| Copyright (C) 1996, 1997 Andreas Dilger,
| Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
| and zlib version 1.2.5, Copyright (C) 1995-2010 (or later),
| Jean-loup Gailly and Mark Adler.
| It was compiled with gcc version 4.5.2.

Recompressing C:\Users\admin\folder\image0009.png
Total length of data found in IDAT chunks = 2032
Reducing truecolor image to grayscale.
IDAT length with method 11 (fm 0 zl 2 zs 2) = 86749
IDAT length with method 12 (fm 1 zl 2 zs 2) = 86856
Could not open output file C:\Users\admin\folder_crush/image000
9.png

Discussion

  • Glenn Randers-Pehrson

    Thanks. I think this failure only occurs when the "-d" option is used, and the binary is built not with DJGPP as was the case in the past. I have revised pngcrush-1.7.23 to use the backslash on Windows platforms. Sorry, I don't have access to a Windows development platform so can't make or test the binary. I have uploaded sources.

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-01-09

    I tried to compile it under Cygwin, and I ran it under cmd.exe. It's still giving the error randomly on some image files.

    Output:
    C:\Users\admin\folder>C:\Users\admin\pngcrush.exe -d "C:\ Users\Oak\Downloads\folder_crush" -bit_depth 1 -plte_len 1 -brute -w 32 -
    c 0 "C:\Users\admin\folder\folder0006.png"

    pngcrush 1.7.23
    Portions copyright (C) 2005 Greg Roelofs
    This is a free, open-source program. Permission is irrevocably
    granted to everyone to use this version of pngcrush without
    payment of any fee.
    Executable name is pngcrush
    It was built with libpng version 1.5.7, and is
    running with libpng version 1.5.7 - December 15, 2011

    | Copyright (C) 1998-2004, 2006-2012 Glenn Randers-Pehrson,
    | Copyright (C) 1996, 1997 Andreas Dilger,
    | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
    | and zlib version 1.2.5, Copyright (C) 1995-2010 (or later),
    | Jean-loup Gailly and Mark Adler.
    | It was compiled with gcc version 3.4.4 (cygming special, gdc 0.12, using dmd
    0.125).

    cygwin warning:
    MS-DOS style path detected: C:\Users\admin\folder_crush
    Preferred POSIX equivalent is: /admin/folder_crush
    CYGWIN environment variable option "nodosfilewarning" turns off this warning.
    Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
    Recompressing C:\Users\admin\folder\folder0006.png
    Total length of data found in IDAT chunks = 2032
    Reducing truecolor image to grayscale.
    IDAT length with method 11 (fm 0 zl 2 zs 2) = 86749
    IDAT length with method 12 (fm 1 zl 2 zs 2) = 86856
    IDAT length with method 13 (fm 2 zl 2 zs 2) = 86870
    IDAT length with method 14 (fm 3 zl 2 zs 2) = 86875
    IDAT length with method 15 (fm 4 zl 2 zs 2) = 86878
    IDAT length with method 16 (fm 5 zl 2 zs 2) = 86749
    IDAT length with method 17 (fm 0 zl 1 zs 0) = 3040
    IDAT length with method 18 (fm 1 zl 1 zs 0) = 4390
    IDAT length with method 19 (fm 2 zl 1 zs 0) = 4390
    IDAT length with method 20 (fm 3 zl 1 zs 0) = 4390
    IDAT length with method 21 (fm 4 zl 1 zs 0) = 4391
    IDAT length with method 22 (fm 5 zl 1 zs 0) = 3040
    IDAT length with method 23 (fm 0 zl 1 zs 1) = 3040
    IDAT length with method 24 (fm 1 zl 1 zs 1) = 4390
    IDAT length with method 25 (fm 2 zl 1 zs 1) = 4390
    IDAT length with method 26 (fm 3 zl 1 zs 1) = 4390
    IDAT length with method 27 (fm 4 zl 1 zs 1) = 4391
    IDAT length with method 28 (fm 5 zl 1 zs 1) = 3040
    Could not open output file C:\Users\admin\folder_crush\badappletr
    ace0006.png

     
  • Glenn Randers-Pehrson

    That's somewhat crazy. Cygwin reads filenames with backslashes but must have
    forward slashes when it writes them. What about the C:\ Does that have to be
    C/ or what?

    Also it cannot be "random" but specifically when the "-d" option is used with
    full pathnames.

     
  • Glenn Randers-Pehrson

    Ah, I see, it wants the "C:\Users\" changed to "/" on a Cygwin platform.

     
  • Glenn Randers-Pehrson

    Does this work (i.e. using a POSIX-style directory name in the -d option)?

    C:\Users\admin\folder>C:\Users\admin\pngcrush.exe -d "/Oak/Downloads/folder_crush" -bit_depth 1 -plte_len 1 -brute -w 32 -
    c 0 "C:\Users\admin\folder\folder0006.png"

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-01-09

    I tried modifying my batch file somewhat so that it would work correctly under Cygwin.
    When in Cygwin, the following line does not work, and it outputs an ~80kB file instead of a ~7kB file like I would expect.

    $ /cygdrive/c/Users/Oak/Downloads/pngcrush.exe -d "/cygdrive/c/Users/Oak/Downlo
    ads/badappletrace_crush" -bit_depth 1 -plte_len 1 -brute -w 32 -c 0 "/cygdrive/
    c/Users/Oak/Downloads/badappletrace/badappletrace0799.png"

    pngcrush 1.7.23
    Portions copyright (C) 2005 Greg Roelofs
    This is a free, open-source program. Permission is irrevocably
    granted to everyone to use this version of pngcrush without
    payment of any fee.
    Executable name is pngcrush
    It was built with libpng version 1.5.7, and is
    running with libpng version 1.5.7 - December 15, 2011

    | Copyright (C) 1998-2004, 2006-2012 Glenn Randers-Pehrson,
    | Copyright (C) 1996, 1997 Andreas Dilger,
    | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
    | and zlib version 1.2.5, Copyright (C) 1995-2010 (or later),
    | Jean-loup Gailly and Mark Adler.
    | It was compiled with gcc version 3.4.4 (cygming special, gdc 0.12, using dmd
    0.125).

    Recompressing /cygdrive/c/Users/Oak/Downloads/badappletrace/badappletrace0799
    .png
    Total length of data found in IDAT chunks = 7158
    Reducing truecolor image to grayscale.
    IDAT length with method 11 (fm 0 zl 2 zs 2) = 87682
    IDAT length with method 12 (fm 1 zl 2 zs 2) = 87739
    IDAT length with method 13 (fm 2 zl 2 zs 2) = 87332
    Could not open output file /cygdrive/c/Users/Oak/Downloads/badappletrace_crush\b
    adappletrace0799.png

     
  • Glenn Randers-Pehrson

    Try pngcrush-1.7.24

    The -d option now takes an optional slash, so if pngcrush is supplying
    the wrong type on some platform, the user can supply the correct one, e.g.,

    /cygdrive/c/Users/Oak/Downloads/pngcrush.exe -d
    "/cygdrive/c/Users/Oak/Downloads/badappletrace_crush/" -bit_depth 1 -plte_len 1 -brute -w 32 -c 0
    "/cygdrive/c/Users/Oak/Downloads/badappletrace/badappletrace0799.png"

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-01-10

    I'm still getting the error, but the slash is facing the correct direction. Oddly enough, I ran the same command three times, and each time, the error occurs after a different "IDAT length with method" iteration, in a seemingly random way. Cygwin output is below:

    $ /cygdrive/c/Users/Oak/Downloads/pngcrush.exe -d "/cygdrive/c/Users/Oak/Downlo
    ads/badappletrace_crush/" -bit_depth 1 -plte_len 1 -brute -w 32 -c 0 "/cygdrive
    /c/Users/Oak/Downloads/badappletrace/badappletrace0799.png"

    pngcrush 1.7.24
    Portions copyright (C) 2005 Greg Roelofs
    This is a free, open-source program. Permission is irrevocably
    granted to everyone to use this version of pngcrush without
    payment of any fee.
    Executable name is pngcrush
    It was built with libpng version 1.5.7, and is
    running with libpng version 1.5.7 - December 15, 2011

    | Copyright (C) 1998-2004, 2006-2012 Glenn Randers-Pehrson,
    | Copyright (C) 1996, 1997 Andreas Dilger,
    | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
    | and zlib version 1.2.5, Copyright (C) 1995-2010 (or later),
    | Jean-loup Gailly and Mark Adler.
    | It was compiled with gcc version 3.4.4 (cygming special, gdc 0.12, using dmd
    0.125).

    Recompressing /cygdrive/c/Users/Oak/Downloads/badappletrace/badappletrace0799
    .png
    Total length of data found in IDAT chunks = 7158
    Reducing truecolor image to grayscale.
    IDAT length with method 11 (fm 0 zl 2 zs 2) = 87682
    IDAT length with method 12 (fm 1 zl 2 zs 2) = 87739
    IDAT length with method 13 (fm 2 zl 2 zs 2) = 87332
    IDAT length with method 14 (fm 3 zl 2 zs 2) = 88421
    IDAT length with method 15 (fm 4 zl 2 zs 2) = 87425
    IDAT length with method 16 (fm 5 zl 2 zs 2) = 87314
    Could not open output file /cygdrive/c/Users/Oak/Downloads/badappletrace_crush/b
    adappletrace0799.png

    $ /cygdrive/c/Users/Oak/Downloads/pngcrush.exe -d "/cygdrive/c/Users/Oak/Downlo
    ads/badappletrace_crush/" -bit_depth 1 -plte_len 1 -brute -w 32 -c 0 "/cygdrive
    /c/Users/Oak/Downloads/badappletrace/badappletrace0799.png"

    pngcrush 1.7.24
    Portions copyright (C) 2005 Greg Roelofs
    This is a free, open-source program. Permission is irrevocably
    granted to everyone to use this version of pngcrush without
    payment of any fee.
    Executable name is pngcrush
    It was built with libpng version 1.5.7, and is
    running with libpng version 1.5.7 - December 15, 2011

    | Copyright (C) 1998-2004, 2006-2012 Glenn Randers-Pehrson,
    | Copyright (C) 1996, 1997 Andreas Dilger,
    | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
    | and zlib version 1.2.5, Copyright (C) 1995-2010 (or later),
    | Jean-loup Gailly and Mark Adler.
    | It was compiled with gcc version 3.4.4 (cygming special, gdc 0.12, using dmd
    0.125).

    Recompressing /cygdrive/c/Users/Oak/Downloads/badappletrace/badappletrace0799
    .png
    Total length of data found in IDAT chunks = 7158
    Reducing truecolor image to grayscale.
    IDAT length with method 11 (fm 0 zl 2 zs 2) = 87682
    IDAT length with method 12 (fm 1 zl 2 zs 2) = 87739
    IDAT length with method 13 (fm 2 zl 2 zs 2) = 87332
    Could not open output file /cygdrive/c/Users/Oak/Downloads/badappletrace_crush/b
    adappletrace0799.png

    $ /cygdrive/c/Users/Oak/Downloads/pngcrush.exe -d "/cygdrive/c/Users/Oak/Downlo
    ads/badappletrace_crush/" -bit_depth 1 -plte_len 1 -brute -w 32 -c 0 "/cygdrive
    /c/Users/Oak/Downloads/badappletrace/badappletrace0799.png"

    pngcrush 1.7.24
    Portions copyright (C) 2005 Greg Roelofs
    This is a free, open-source program. Permission is irrevocably
    granted to everyone to use this version of pngcrush without
    payment of any fee.
    Executable name is pngcrush
    It was built with libpng version 1.5.7, and is
    running with libpng version 1.5.7 - December 15, 2011

    | Copyright (C) 1998-2004, 2006-2012 Glenn Randers-Pehrson,
    | Copyright (C) 1996, 1997 Andreas Dilger,
    | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
    | and zlib version 1.2.5, Copyright (C) 1995-2010 (or later),
    | Jean-loup Gailly and Mark Adler.
    | It was compiled with gcc version 3.4.4 (cygming special, gdc 0.12, using dmd
    0.125).

    Recompressing /cygdrive/c/Users/Oak/Downloads/badappletrace/badappletrace0799
    .png
    Total length of data found in IDAT chunks = 7158
    Reducing truecolor image to grayscale.
    IDAT length with method 11 (fm 0 zl 2 zs 2) = 87682
    IDAT length with method 12 (fm 1 zl 2 zs 2) = 87739
    IDAT length with method 13 (fm 2 zl 2 zs 2) = 87332
    IDAT length with method 14 (fm 3 zl 2 zs 2) = 88421
    IDAT length with method 15 (fm 4 zl 2 zs 2) = 87425
    IDAT length with method 16 (fm 5 zl 2 zs 2) = 87314
    IDAT length with method 17 (fm 0 zl 1 zs 0) = 10123
    IDAT length with method 18 (fm 1 zl 1 zs 0) = 11712
    IDAT length with method 19 (fm 2 zl 1 zs 0) = 9905
    IDAT length with method 20 (fm 3 zl 1 zs 0) = 13384
    IDAT length with method 21 (fm 4 zl 1 zs 0) = 9657
    IDAT length with method 22 (fm 5 zl 1 zs 0) = 9946
    IDAT length with method 23 (fm 0 zl 1 zs 1) = 10123
    IDAT length with method 24 (fm 1 zl 1 zs 1) = 11712
    IDAT length with method 25 (fm 2 zl 1 zs 1) = 9905
    IDAT length with method 26 (fm 3 zl 1 zs 1) = 13384
    IDAT length with method 27 (fm 4 zl 1 zs 1) = 9657
    IDAT length with method 28 (fm 5 zl 1 zs 1) = 9946
    IDAT length with method 29 (fm 0 zl 2 zs 0) = 9486
    IDAT length with method 30 (fm 1 zl 2 zs 0) = 10807
    IDAT length with method 31 (fm 2 zl 2 zs 0) = 9593
    IDAT length with method 32 (fm 3 zl 2 zs 0) = 12561
    IDAT length with method 33 (fm 4 zl 2 zs 0) = 9390
    IDAT length with method 34 (fm 5 zl 2 zs 0) = 9579
    IDAT length with method 35 (fm 0 zl 2 zs 1) = 9486
    IDAT length with method 36 (fm 1 zl 2 zs 1) = 10807
    IDAT length with method 37 (fm 2 zl 2 zs 1) = 9593
    IDAT length with method 38 (fm 3 zl 2 zs 1) = 12561
    IDAT length with method 39 (fm 4 zl 2 zs 1) = 9390
    IDAT length with method 40 (fm 5 zl 2 zs 1) = 9579
    IDAT length with method 41 (fm 0 zl 3 zs 0) = 9254
    IDAT length with method 42 (fm 1 zl 3 zs 0) = 10592
    IDAT length with method 43 (fm 2 zl 3 zs 0) = 9354
    IDAT length with method 44 (fm 3 zl 3 zs 0) = 12044
    IDAT length with method 45 (fm 4 zl 3 zs 0) = 9098
    IDAT length with method 46 (fm 5 zl 3 zs 0) = 9343
    IDAT length with method 47 (fm 0 zl 3 zs 1) = 9254
    IDAT length with method 48 (fm 1 zl 3 zs 1) = 10592
    IDAT length with method 49 (fm 2 zl 3 zs 1) = 9354
    IDAT length with method 50 (fm 3 zl 3 zs 1) = 12044
    IDAT length with method 51 (fm 4 zl 3 zs 1) = 9098
    IDAT length with method 52 (fm 5 zl 3 zs 1) = 9343
    IDAT length with method 53 (fm 0 zl 4 zs 0) = 6491
    IDAT length with method 54 (fm 1 zl 4 zs 0) = 7646
    IDAT length with method 55 (fm 2 zl 4 zs 0) = 5354
    IDAT length with method 56 (fm 3 zl 4 zs 0) = 8894
    IDAT length with method 57 (fm 4 zl 4 zs 0) = 5317
    IDAT length with method 58 (fm 5 zl 4 zs 0) = 5442
    IDAT length with method 59 (fm 0 zl 4 zs 1) = 6516
    IDAT length with method 60 (fm 1 zl 4 zs 1) = 7667
    IDAT length with method 61 (fm 2 zl 4 zs 1) = 5344
    IDAT length with method 62 (fm 3 zl 4 zs 1) = 8781
    IDAT length with method 63 (fm 4 zl 4 zs 1) = 5306
    IDAT length with method 64 (fm 5 zl 4 zs 1) = 5425
    IDAT length with method 65 (fm 0 zl 5 zs 0) = 6280
    IDAT length with method 66 (fm 1 zl 5 zs 0) = 7544
    IDAT length with method 67 (fm 2 zl 5 zs 0) = 5280
    IDAT length with method 68 (fm 3 zl 5 zs 0) = 8806
    IDAT length with method 69 (fm 4 zl 5 zs 0) = 5260
    IDAT length with method 70 (fm 5 zl 5 zs 0) = 5354
    IDAT length with method 71 (fm 0 zl 5 zs 1) = 6335
    IDAT length with method 72 (fm 1 zl 5 zs 1) = 7570
    IDAT length with method 73 (fm 2 zl 5 zs 1) = 5290
    Could not open output file /cygdrive/c/Users/Oak/Downloads/badappletrace_crush/b
    adappletrace0799.png

     
  • Glenn Randers-Pehrson

    Oddly enough, I ran the same command three times, and each time, the error
    occurs after a different "IDAT length with method" iteration, in a
    seemingly random way.

    Very odd. Are you running out of disk space or something, to make
    the "open" fail after it has succeeded a few times?

     
  • Glenn Randers-Pehrson

    Please try with the "-v" (verbose) option. The output will be voluminous so please upload it as an attachment rather than embedding it in the comment.

     

Log in to post a comment.