apt-encoder icon indicating copy to clipboard operation
apt-encoder copied to clipboard

Command Line Error (Linux)

Open libmarleu opened this issue 3 years ago • 3 comments

Hi! I'm having an error when I try to feed my images in to the program...

Here's the commands I used

convert testcard.png -flatten -resize 909x511 testcard.pgm

convert testcard.png -flatten -resize 909x511 testcard2.pgm

./apt-encode testcard.pgm testcard2.pgm > encode.raw

And here's the error I get:

apt-encode: apt-encode.cpp:79: void Image::load(): Assertion `buf[1] == '2'' failed.                                                                                                                               
Aborted

libmarleu avatar May 08 '21 16:05 libmarleu

The convert command (ImageMagick) generates P5 files by default. P5 files are PGM files encoded in binary instead of ASCII, but apt-encoder expects an ASCII-encoded PGM file (P2). I've personally used GIMP to generate the images, and I am not familiar with how ImageMagick works. I've seen a suggestion on the ImageMagick forum that recommends to Use -depth 8 or -compress none..

Can you try it that way and let me know if it works? Or try to convert your image with GIMP instead?

gkbrk avatar May 08 '21 16:05 gkbrk

Wow! Thank you for the prompt response!

So I tried a few things + what you recommended

First I tried what you said:

My Commands:

pi@raspberry:~ $ convert testcard.png -resize 909x909 -depth 8 testcard.pgm
pi@raspberry:~ $ convert testcard.png -resize 909x909 -depth 8 testcard2.pgm
pi@raspberry:~ $ ./apt-encoder/a.out ./testcard.pgm ./testcard2.pgm

Error Response:

a.out: apt-encode.cpp:79: void Image::load(): Assertion `buf[1] == '2'' failed.
Aborted

I also tried the -compress none and also I tried both together, but they both gave me the same response...

Next I tried another forum recommended idea.

My Commands:

pi@raspberry:~ $ convert testcard.png testcard.jp2
pi@raspberry:~ $ convert testcard.jp2 -compress none pgm:- | tr -s '\012\015' ' '  > testcard.pgm
pi@raspberry:~ $ convert testcard.jp2 -compress none pgm:- | tr -s '\012\015' ' '  > testcard2.pgm
pi@raspberry:~ $ ./apt-encoder/a.out ./testcard.pgm ./testcard2.pgm

Error Response:

a.out: apt-encode.cpp:80: void Image::load(): Assertion `buf[2] == '\n'' failed.
Aborted

I'm slightly confused as to what I should do/try next...

libmarleu avatar May 08 '21 17:05 libmarleu

did you convert into ascii? because it seems like the conversion software isn't using ascii. using raw conversion format repilacated your error: apt color2.pgm > encode.raw Assertion failed: buf[1] == '2', file apt2.cpp, line 79 Solution: use gimp or use convert filein -compress none fileout.pgm it works for me

CryptoDude3 avatar Jul 23 '22 19:07 CryptoDude3