Jpeg on lcd160cr

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
Seb60
Posts: 7
Joined: Wed Mar 14, 2018 11:33 am

Jpeg on lcd160cr

Post by Seb60 » Mon Mar 19, 2018 7:13 pm

Hello,

I have a problem, I tried several solution without success!
I already read on the forum solutions but impossible to display my image..

instead of my image I have this:
Image

or http://gofile.me/3qDFk/bhSbfcOc1

my code:

Code: Select all

import lcd160cr
import pyb



lcd = lcd160cr.LCD160CR('X')
pyb.delay(5000)
lcd.erase()

lcd.set_orient(lcd160cr.LANDSCAPE)

lcd.rect(0,0,160,125)

lcd.set_text_color(lcd.rgb(255, 0, 0), lcd.rgb(0, 0, 0))
lcd.set_font(2, scale=0)
lcd.set_pos(25, 60)

lcd.write("Hello les amis")
pyb.delay(2000)
lcd.erase()

        
#image = bytearray(1000)
with open('/sd/pics/image.jpg', 'r') as f:
        image = f.read()

lcd.set_pos(0,0)
lcd.jpeg(image)
thx
Seb

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Jpeg on lcd160cr

Post by pythoncoder » Tue Mar 20, 2018 6:07 am

You need to read the file as a binary file ("rb"). Also check carefully that your JPEG meets all the requirements in the docs.
Peter Hinch
Index to my micropython libraries.

Seb60
Posts: 7
Joined: Wed Mar 14, 2018 11:33 am

Re: Jpeg on lcd160cr

Post by Seb60 » Tue Mar 20, 2018 8:00 am

I'm sorry but I'm trying to convert my jpg, but it does not work!

I tried for the web,
without exif,
etc ..

I can not display it at all ..

Thank you

Seb

chuckbook
Posts: 135
Joined: Fri Oct 30, 2015 11:55 pm

Re: Jpeg on lcd160cr

Post by chuckbook » Tue Mar 20, 2018 10:26 am

Can you provide a sample jpeg image?

Seb60
Posts: 7
Joined: Wed Mar 14, 2018 11:33 am

Re: Jpeg on lcd160cr

Post by Seb60 » Tue Mar 20, 2018 10:46 am

Yes,
image.jpg
image.jpg (10.75 KiB) Viewed 5710 times
thx,

Seb

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Jpeg on lcd160cr

Post by pythoncoder » Wed Mar 21, 2018 5:59 am

I think you'll need to provide a link to an image file so that we can download it. I can't see a way to retrieve the JPEG file from your post.
Peter Hinch
Index to my micropython libraries.

chuckbook
Posts: 135
Joined: Fri Oct 30, 2015 11:55 pm

Re: Jpeg on lcd160cr

Post by chuckbook » Wed Mar 21, 2018 8:40 am

Try to filter the jpeg image as recommended:

Code: Select all

jpegtran image.jpg > image_opt.jpg
This will remove most of the additional flags that LCD160CR doesn't support.

Seb60
Posts: 7
Joined: Wed Mar 14, 2018 11:33 am

Re: Jpeg on lcd160cr

Post by Seb60 » Wed Mar 21, 2018 11:58 am

Hi,

sorry, I have an error with

Code: Select all

 jpegtran image.jpg > image_opt.jpg
My jpg original: http://gofile.me/3qDFk/ksK7lgKt5

thx
Seb

chuckbook
Posts: 135
Joined: Fri Oct 30, 2015 11:55 pm

Re: Jpeg on lcd160cr

Post by chuckbook » Wed Mar 21, 2018 1:06 pm

jpegtran has to be run on a host computer. Try this one.
Attachments
image_opt.jpg
image_opt.jpg (10.61 KiB) Viewed 5664 times

Seb60
Posts: 7
Joined: Wed Mar 14, 2018 11:33 am

Re: Jpeg on lcd160cr

Post by Seb60 » Wed Mar 21, 2018 4:31 pm

Yes, it works, but it appears too big ...

Post Reply