Reputation: 53
I have a 3d printer with a webcam on it, and I can view snapshots of the webcam if I just go to the URL http://my-printer/webcam/?action=snapshot&cacheBust=$(date +%s)
. I've been trying to use imgcat to output the image to my terminal, but it looks as if the image is created or saved with some data that is making that difficult. But if I run the downloaded image through convert
or mogrify
before imgcat
then it seems to work fine (in most cases), but it just takes much longer. So it seems to be an issue with how the image is being saved.
It doesn't matter how I get the image (go to browser and save it, use curl/wget, or pass the image URL to imgcat
, it all results in the same thing).
For the below output, ill be running the same commands on a known JPEG that is working file via imgcat. I also intentionally didn't add the .jpeg
extension to avoid any of the commands im using from trying to infer the image type, in case it actually wasn't a jpeg.
When I run the file
or exiftool
command on the snapshot file, it shows that it is in fact a JPEG image:
~/Documents/scripts/bash/print-stats(✓)$ file images/snapshot
images/snapshot: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1920x1080, components 3
~/Documents/scripts/bash/print-stats(✓)$ exiftool images/snapshot
ExifTool Version Number : 11.59
File Name : snapshot
Directory : images
File Size : 277 kB
File Modification Date/Time : 2024:04:13 10:24:30-07:00
File Access Date/Time : 2024:04:13 11:04:45-07:00
File Inode Change Date/Time : 2024:04:13 10:24:30-07:00
File Permissions : rw-r--r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
JFIF Version : 1.01
Resolution Unit : None
X Resolution : 1
Y Resolution : 1
Image Width : 1920
Image Height : 1080
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1920x1080
Megapixels : 2.1
But imgcat
still fails to load it. When I use convert
to create a new .png format image from the jpeg and use imgcat
on that, it does work. But then when I use convert to go from a png back to jpeg, it doesn't work.
I notice that the file
output of the snapshot has less output than the working jpeg image, so I used convert
to set some of the values, but that didn't seem to resolve it.
Output below with a comparison to a working JPEG image on the right:
And using mogrify
instead of convert
pretty much results in the same issue.
What could be wrong with the jpeg that's getting downloaded from my printers webcam? I'm attaching it below (hopefully SO/Imgur doesn't modify the images too much, so you can see exactly what im working with):
P.S. Its also worth noting that the image loads fine when I open it in any image viewer on my Mac.
I uploaded the output of the following commands to dropmefiles here:
curl -ksL --verbose --compressed --insecure http://192.168.0.50/webcam/?action=snapshot --output snapshot.jpeg --dump-header snapshot-curl-headers.txt 2>snapshot-curl-verbose.txt
identify -verbose snapshot.jpeg > snapshot-identify-verbose.txt
exiftool -verbose snapshot.jpeg > snapshot-exiftool-verbose.txt
exiftool snapshot.jpeg > snapshot-exiftool.txt
Thank you.
Upvotes: 0
Views: 77