sips/magick cmd to build "safe" jpg files for html5?

Hi,

TL;DR: does anyone have a sips or magickt command that will “fix” bad JPG files so they can be displayed via Solar2D generated HTML apps?

Most of my jpg files display ok, but a few don’t (looks like a TV set with random noise signal) . The bad ones were hand created in macOS “Paintbrush” as simply black squares with ASCII text (a number). After tracing my display problem, I can summarize with these two jpg files: (info from: “file *.jpg”)

bad.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=1], baseline, precision 8, 275x452, components 1

good.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 72x72, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=1], baseline, precision 8, 271x452, components 3

And, more detailed “diff” of exif differences:

2c2
< File Name                       : bad.jpg
---
> File Name                       : good.jpg
4,7c4,7
---
16,17d15
19c17
< Exif Image Width                : 452
---
> Exif Image Width                : 271
20a19,20
22c22
< Profile Version                 : 2.0.0
---
> Profile Version                 : 2.2.0
24c24
< Color Space Data                : GRAY
---
> Color Space Data                : RGB
26c26
---
30c30
< Device Manufacturer             : none
---
> Device Manufacturer             : appl
37,72c37,78
< Profile Description             : Generic Gray Gamma 2.2 Profile
< Profile Description ML          : Generic Gray Gamma 2.2 Profile
< Profile Copyright               : Copyright Apple Inc., 2012
< Media White Point               : 0.95045 1 1.08905
< Gray Tone Reproduction Curve    : (Binary data 2060 bytes, use -b option to extract)
< Image Width                     : 275
---
> Profile Description             : Generic RGB Profile
> Profile Description ML          : Generic RGB Profile
> Profile Copyright               : Copyright 2007 Apple Inc., all rights reserved.
> Media White Point               : 0.95047 1 1.0891
> Red Matrix Column               : 0.4543 0.24191 0.01489
> Green Matrix Column             : 0.35335 0.67363 0.09064
> Blue Matrix Column              : 0.15665 0.08446 0.71957
> Red Tone Reproduction Curve     : (Binary data 14 bytes, use -b option to extract)
> Chromatic Adaptation            : 1.04788 0.02292 -0.0502 0.02957 0.99049 -0.01706 -0.00923 0.01508 0.75165
> Blue Tone Reproduction Curve    : (Binary data 14 bytes, use -b option to extract)
> Green Tone Reproduction Curve   : (Binary data 14 bytes, use -b option to extract)
> Image Width                     : 271
76,78c82,85
< Color Components                : 1
< Image Size                      : 275x452
< Megapixels                      : 0.124
---
> Color Components                : 3
> Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
> Image Size                      : 271x452
> Megapixels                      : 0.122

thanks!

Stan

It could also be related to this issue; the HTML build is having problems with JPG/JPEG.