Coder Social home page Coder Social logo

Comments (4)

markusdd avatar markusdd commented on June 26, 2024

Ok, checked the code further and when using the shopcart URL used to get the data for this dialog, I see no immidiate issue, the 96x96 replacement to 900x900 should still be valid.

grafik

With this, using imageList, we actually could make the parts page even cooler by making it possible to flip through all big images, but that is more a feature request.

The Image format is jpg. Is that what we expect?
Seems pretty standard, a bit confused why this would fail now.

from kicad-jlcpcb-tools.

markusdd avatar markusdd commented on June 26, 2024

Ok, that is wild.
I enforced interpreting the byte stream as a JPEG instead of auto detection:

    def get_scaled_bitmap(self, url, width, height):
        """Download a picture from a URL and convert it into a wx Bitmap"""
        content = requests.get(url, timeout=10).content
        self.logger.info("Fetching Image %s", str(url))
        io_bytes = io.BytesIO(content)
        self.logger.info("Image Byte Content %s", str(io_bytes))
        image = wx.Image(io_bytes, type=wx.BITMAP_TYPE_JPEG)
        image = image.Scale(width, height, wx.IMAGE_QUALITY_HIGH)
        result = wx.Bitmap(image)
        return result

and then I get this:

grafik

But the URL is 100% positivly pointing to a jpg:

https://assets.lcsc.com/images/lcsc/900x900/20221227_FH--Guangdong-Fenghua-Advanced-Tech-0805B152K500NT_C1717_front.jpg

I'm a bit baffled. Any ideas?

EDIT: The header of the downloaded file definetly also advertises it as jpeg and no ther image viewer is complaining. I'm more thinking this is an issue with the Byte-IO-Stream.
grafik

from kicad-jlcpcb-tools.

markusdd avatar markusdd commented on June 26, 2024

ok haha: I think we have our issue:

2024.03.05 14:45:49 - INFO - get_scaled_bitmap -  Fetching Image https://assets.lcsc.com/images/lcsc/900x900/20221227_FH--Guangdong-Fenghua-Advanced-Tech-0805B152K500NT_C1717_front.jpg
2024.03.05 14:45:49 - INFO - get_scaled_bitmap -  Image Byte Content b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">\n<TITLE>ERROR: The request could not be satisfied</TITLE>\n</HEAD><BODY>\n<H1>403 ERROR</H1>\n<H2>The request could not be satisfied.</H2>\n<HR noshade size="1px">\nRequest blocked.\nWe can\'t connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.\n<BR clear="all">\nIf you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.\n<BR clear="all">\n<HR noshade size="1px">\n<PRE>\nGenerated by cloudfront (CloudFront)\nRequest ID: Up1AOdk5pjWucz0rRMwp0pflI493h8hbj6tWAevIERNzZJNcp5j95g==\n</PRE>\n<ADDRESS>\n</ADDRESS>\n</BODY></HTML>'

from kicad-jlcpcb-tools.

markusdd avatar markusdd commented on June 26, 2024

Ok, so they are filtering for Python User Agent.
Then let's pretend we are a browser:

headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
        }
        content = requests.get(url, headers=headers, timeout=10).content

And it works :D
grafik

I will submit a PR to fix this

from kicad-jlcpcb-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.