01-14-2020 17:56
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-14-2020 17:56
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I read this older blog post, "https://dev.fitbit.com/blog/2018-05-09-introducing-the-imagepicker-and-image-api/"
that mentions the following:
"One approach which tends to work well is to convert the source image into a jpeg with medium compression (40-50), then use the JPEG API on the device to save the jpeg as a txi file. "
Now I'm trying to convert my existing bundled jpegs (located within `/resources` directory) to `.txi`, however not getting any luck.
Tried the following:
jpeg.decodeSync('bg-blue-348.jpg', outFileName)
jpeg.decodeSync('./resources/assets/bg-blue-348', outFileName)
Any help would be appreciated, thank you!
Answered! Go to the Best Answer.
Accepted Solutions
01-14-2020 21:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-14-2020 21:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Here's an extract from something of mine (that works):
const dataDir = "/private/data/";
jpeg.decodeSync('/mnt/assets/resources/0.jpg', dataDir+'0.txi');
Unfortunately, that error you're getting is rather generic. It could mean unexpected JPEG format (eg, progressive), invalid destination directory, pre-existing destination file (and not using overwrite:true), and more.
Gondwana Software

01-14-2020 18:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-14-2020 18:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Try /mnt/assets/resources/ instead of ./resources
Might also need file extension.
Gondwana Software

01-14-2020 20:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-14-2020 20:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Unfortunately, still no luck.

01-14-2020 21:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-14-2020 21:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Here's an extract from something of mine (that works):
const dataDir = "/private/data/";
jpeg.decodeSync('/mnt/assets/resources/0.jpg', dataDir+'0.txi');
Unfortunately, that error you're getting is rather generic. It could mean unexpected JPEG format (eg, progressive), invalid destination directory, pre-existing destination file (and not using overwrite:true), and more.
Gondwana Software

01-14-2020 22:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-14-2020 22:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Ah I see my mistake, I have my images located within resources/assets, so my absolute path was `/mnt/assets/resources/assets/<image>.jpg`, instead I was using `/mnt/resources/assets/<image>.jpg`.
Thanks @Gondwana !
01-14-2020 22:45
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-14-2020 22:45
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
👍
Gondwana Software

01-15-2020 01:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-15-2020 01:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
If you use PNG files in your project, they are automatically converted to TXI during the build process.

