Open Dingo64 opened 7 years ago
I was thinking it would be a good idea to host some, so yes I'd like to do this.
But in the mean time, what happens when you try to build with libjpeg support? Could you post the output of ./configure and your distro/version?
Binaries would be awesome, thanks!
Here's output from my Debian 8.8 Jessie AMD64 of configure:
CC is "/usr/bin/cc"
CFLAGS is "-Ofast -march=native -mtune=native -std=gnu99 "
AR is "/usr/bin/ar"
PREFIX is "/usr/local"
BINPREFIX is "/usr/local/bin"
LIBPREFIX is "/usr/local/lib"
INCPREFIX is "/usr/local/include"
SHAREPREFIX is "/usr/local/share/resdet"
PCPREFIX is "/usr/local/lib/pkgconfig"
Testing for fftw3f... ok
Testing for jpeglib.h... ok
Testing for jpeg... ok
Testing for magic.h... not found
Testing for libpng... ok
Testing for mjpegtools... not found
Testing for MagickWand... not found
Testing for m... ok
Generating lib/resdet.pc
So JPEG and PNG libraries are found. Now output from make:
/usr/bin/cc -o resdet -DHAVE_FFTW -DHAVE_LIBJPEG -DHAVE_LIBPNG -I/usr/include/libpng12 src/resdet.o lib/libresdet.a -ljpeg -lm -lfftw3f -lpng12
/usr/bin/cc -o stat -DHAVE_FFTW -DHAVE_LIBJPEG -DHAVE_LIBPNG -I/usr/include/libpng12 src/stat.o lib/libresdet.a -ljpeg -lm -lfftw3f -lpng12
/usr/bin/cc -o profile -DHAVE_FFTW -DHAVE_LIBJPEG -DHAVE_LIBPNG -I/usr/include/libpng12 src/profile.o lib/libresdet.a -ljpeg -lm -lfftw3f -lpng12
Seems OK to me. And now when I try to analyze a JPEG image:
Invalid image
And that's it. Works fine with PNGs. I don't see a way to read PNG files from stdin with resdet so I have to first convert JPEGs into PNGs, store them and then run resdet. While this method works it's not very handy.
Thanks, this was actually just a dumb bug in the fallback filetype detection. If you pull and rebuilt it should work.
I tried to compile it with Cygwin for Windows and while it compiles fine and does "-version":
$ ./resdet -version
Usage: ./resdet -h -m <method> -v <verbosity> image
it doesn't want to work even on PNG images:
$ ./resdet -version TEST2.png
Aborted (core dumped)
Output from configure from Cygwin:
$ ./configure
CC is "/usr/bin/cc"
CFLAGS is "-Ofast -march=native -mtune=native -std=gnu99 "
AR is "/usr/bin/ar"
PREFIX is "/usr/local"
BINPREFIX is "/usr/local/bin"
LIBPREFIX is "/usr/local/lib"
INCPREFIX is "/usr/local/include"
SHAREPREFIX is "/usr/local/share/resdet"
PCPREFIX is "/usr/local/lib/pkgconfig"
Testing for fftw3f... ok
Testing for jpeglib.h... ok
Testing for jpeg... ok
Testing for magic.h... not found
Testing for libpng... ok
Testing for mjpegtools... not found
Testing for MagickWand... not found
Testing for m... ok
Generating lib/resdet.pc
And from make:
/usr/bin/cc -o resdet -DHAVE_FFTW -DHAVE_LIBJPEG -DHAVE_LIBPNG -I/usr/include/libpng16 src/resdet.o lib/libresdet.a -ljpeg -lm -lfftw3f -lpng16
/usr/bin/cc -o stat -DHAVE_FFTW -DHAVE_LIBJPEG -DHAVE_LIBPNG -I/usr/include/libpng16 src/stat.o lib/libresdet.a -ljpeg -lm -lfftw3f -lpng16
/usr/bin/cc -o profile -DHAVE_FFTW -DHAVE_LIBJPEG -DHAVE_LIBPNG -I/usr/include/libpng16 src/profile.o lib/libresdet.a -ljpeg -lm -lfftw3f -lpng16
If you ever consider to make a Windows build perhaps this will be helpful. Anyway- thanks for a nice tool!
I grabbed new code and it works great under Debian 8.8 with JPEGs! Great job! Thank you!
Good to hear, I'll leave this open while I investigate setting up cross platform builds. The code should all be standard C, so building for Windows natively with mingw or clang rather than cygwin should be possible. But I haven't tested this in a long time.
Digital Mars C Compiler for Windows says:
dmc src/resdet.c -Iinclude/ -Ilib/
Error C:\\dm\bin\..\include\unistd.h 6: "unistd.h is not
for Windows use"
--- errorlevel 1
Oh yeah, this is used in the tools for command line option parsing. I was thinking more about the library code. But I'll look into it. There isn't anything inherently platform dependent about the project.
I think I am quite close to compile it on Debian for Win32:
# i686-w64-mingw32-gcc -std=c11 src/resdet.c -Iinclude/ -Ilib/ -Ilib/kissfft
/tmp/ccfVDSmh.o:resdet.c:(.text+0x7d): undefined reference to `resdet_methods'
/tmp/ccfVDSmh.o:resdet.c:(.text+0x1bc): undefined reference to `resdet_open_context'
/tmp/ccfVDSmh.o:resdet.c:(.text+0x205): undefined reference to `resdet_get_method'
/tmp/ccfVDSmh.o:resdet.c:(.text+0x23d): undefined reference to `resdetect_file'
/tmp/ccfVDSmh.o:resdet.c:(.text+0x24d): undefined reference to `resdet_close_context'
Hi, just wondering if there's still plans for cross platform support and static binaries?
@BradleyDS2 I was able to compile without issue using MSYS2. The caveat is that this is linked with msys-2.0.dll and so msys will need to be installed (or at least this dll) to run it. resdet-msys2.zip
This was built using the following config.mak
CC=/usr/bin/cc
AR=/usr/bin/ar
CFLAGS=-Ofast -march=x86-64 -mtune=generic
PREFIX=/usr/local
BINPREFIX=/usr/local/bin
LIBPREFIX=/usr/local/lib
INCPREFIX=/usr/local/include
SHAREPREFIX=/usr/local/share/resdet
PCPREFIX=/usr/local/lib/pkgconfig
DEFS= -DHAVE_LIBJPEG=1 -DHAVE_LIBPNG=1 -I/usr/include/libpng16
LIBS= -lpng16 -lz -ljpeg -static
This can be reproduced using the existing build script simply by installing msys2, then using the included package manager to install gcc, make, and pkg-config (libjpeg and libpng aren't included and need to be compiled separately.)
Builds within the vanilla mingw environment (no msys-2.0.dll dependency) succeed but seem to have issues with read failures within libjpeg/libpng which I haven't yet found an explanation for.
I haven't attempted to port to VS/cl.exe
Awesome! Are there any plans to add prebuilt binaries to the releases page in future?
Sure, I'll revisit setting up non-msys dependent builds and add an official releases based on that going forward. I haven't made it a priority since activity on this ticket died down, so it's helpful for me to know that there's a real need for this. Thanks!
That's awesome, thanks a lot!
There's no need for you to thank me though, I wasn't sure if I'd even get a response, so I'm really grateful to you for responding and doing all of this.
Hi, I second this idea! It will be so much help if you could put the stable binaries under the release tag. It is such a great tool!
Sorry for the lack of updates here, shortly after the last activity on this ticket my Windows machine was rendered unusable in a flood, effectively putting this on hold. I looked into the alternatives (mingw cross compilation, the auto-expiring dev VMs from Microsoft, just buying another license) but nothing was particularly attractive. I'll have to repair the machine eventually, so I'll update once that happens or a better alternative crops up.
Hi all I already install libpng and libjpeg on my system(Ubuntu 16.04). However when I run resdet test.png it got the errors as bellows :
$ resdet test.png
Invalid image
Can you guys give me any advises. Thanks
@0x09 say:
I looked into the alternatives
Interestingly, and under ReactOS (https://reactos.org/), you can compile programs for Windows?
@rogerallen741 say:
Invalid image
Try to test. In: https://github.com/0x09/resdet/blob/20926fb535b04d462f287a60163d9094a81e745d/lib/resdet.c#L119-L126 put another error from: https://github.com/0x09/resdet/blob/20926fb535b04d462f287a60163d9094a81e745d/include/resdet.h#L32-L37 example:
return RDENOMEM;
Hi @rogerallen741, can you post your config.mak and the image file? In case it’s an issue with detecting libpng, resdet has a built-in pgm reader you can try in the mean time which should work. e.g. with imagemagick’s convert util:
convert test.png test.pgm
./resdet test.pgm
Hi @zvezdochiot i replaced the RDEINVAL and built again. Also test with same image(test.png), while it output the same results: Invalid image lol...
Hi @0x09 here is the config.mak
CC=/usr/bin/cc
AR=/usr/bin/ar
CFLAGS=-Ofast -march=native -mtune=native -std=gnu99
PREFIX=/usr/local
BINPREFIX=/usr/local/bin
LIBPREFIX=/usr/local/lib
INCPREFIX=/usr/local/include
PCPREFIX=/usr/local/lib/pkgconfig
HAVE_FFTW=3
HAVE_LIBJPEG=1
HAVE_LIBPNG=1
DEFS= -DHAVE_LIBJPEG -DHAVE_LIBPNG=1 -I/usr/include/libpng12
LIBS= -ljpeg -lm -lfftw3f -lpng12
Here is the testing image(test.png)
I also convert test.png to test.pgm by imagemagick. Here is the results:
*** stack smashing detected ***: resdet terminated
Aborted (core dumped)
@rogerallen741 say:
while it output the same results
A I was hoping so. So still reading the image. To be sure, check a similar replacement in: https://github.com/0x09/resdet/blob/2d870afce35f3bf98f361c60eaa53b4545fa4d2e/lib/image.c#L78-L82 and test.
And add before return
:
printf("Mime: %s", c);
lpng12
Ah, this is linking with libpng 1.2 whereas resdet really only targets the current release of 1.6. The configure script definitely should be changed to take this into consideration before treating libpng as "enabled" as it did here. I'm able to process this successfully on debian using libpng16. If you can't install libpng16 but have access to ImageMagick's MagickWand library, resdet can use that to read everything the png source can + more.
The pgm issue is separate and was fun to track down as it differs by OS/libc, but that's now fixed in 21e21481fc3887bf87731c045e72e5a4b78ec2d7 -- thanks for finding this.
@0x09 say:
this is linking with libpng 1.2 whereas resdet really only targets the current release of 1.6.
$ ldd /usr/bin/resdet
linux-gate.so.1 => (0xb76f2000)
libresdet.so.0 => /usr/lib/i386-linux-gnu/libresdet.so.0 (0xb76a4000)
libjpeg.so.8 => /usr/lib/i386-linux-gnu/libjpeg.so.8 (0xb766b000)
libmagic.so.1 => /usr/lib/i386-linux-gnu/libmagic.so.1 (0xb764a000)
libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xb7624000)
libfftw3f.so.3 => /usr/lib/i386-linux-gnu/libfftw3f.so.3 (0xb7427000)
libpng12.so.0 => /lib/i386-linux-gnu/libpng12.so.0 (0xb73fd000)
libMagickWand.so.5 => /usr/lib/i386-linux-gnu/libMagickWand.so.5 (0xb72e0000)
libMagickCore.so.5 => /usr/lib/i386-linux-gnu/libMagickCore.so.5 (0xb7018000)
...
Everything works. Maybe because of imagemagick?
@0x09 say:
resdet really only targets the current release of 1.6
Maybe you should take a closer look at libiio
(https://github.com/mnhrdt/iio).
@0x09: You mean resdet(current version) support libpng 1.6 only, so I should install libpng 1.6 instead libpng 1.2 ?
@zvezdochiot: I add the printf("Mime: %s", c). Here is the results. Apparently, the code works fine now but i have totally no idea why it can works ....
$ resdet test.png
Mime: image/pnggiven: 474x474
best guess: 316x316
all width height
316 (68.93%) 316 (66.46%)
240 (55.47%)
196 (55.01%)
After i remove the printf(), the code also can work properly.
@rogerallen741 say:
so I should install libpng 1.6 instead libpng 1.2 ?
Not instead, but beside. There are many things that depend on libpng 1.2 on the system.
@zvezdochiot thanks for the link, that looks like a neat project.
@rogerallen741 since you do have ImageMagick's libraries installed now you shouldn't actually need to install the newer version of libpng for this and may just want to disable it, since again ImageMagick supports that and far more formats. The libpng image reader is really only provided for instances where ImageMagick is not available.
Also, if you have any further issues or just want to continue discussion please open a new github issue for this as we're potentially sending quite a lot of notifications to folks who were only watching this one for static binary support.
@rogerallen741 say:
After i remove the printf(), the code also can work properly.
Seems understand. Replace: https://github.com/0x09/resdet/blob/21e21481fc3887bf87731c045e72e5a4b78ec2d7/include/resdet.h#L25-L30 on the:
typedef enum RDError {
RDEOK = 0,
RDENOMEM,
RDEINTERNAL,
RDEINVAL,
RDENONE
} RDError;
and return RDEINVAL to: https://github.com/0x09/resdet/blob/2d870afce35f3bf98f361c60eaa53b4545fa4d2e/lib/image.c#L78-L82
I installed libpng and libjpeg on my system. Compiled resdet but it still doesn't work with jpegs. Would it be possible for you to provide static binary for Linux? (Or maybe even for Windows?)