1

I have used python to upload an image from my desktop to imgur in the jpg format but it converts the image to jpeg format and this is no good for the use I am looking to use this for. I was wondering if anyone knows how to keep it from changing. here is my code with my keys taken out.

from imgurpython import ImgurClient

def uploadimage():
    client_id = 'hi'
    client_secret = 'hi'

    client = ImgurClient(client_id, client_secret)

    uploadedImage = client.upload_from_path(r"C:\Users\will_\Documents\PSA Card Project Files\Price Checker\IMG_1632.jpg", config=None, anon=True)
    link = "{0}".format(uploadedImage['link'])
    print(link)

uploadimage()

Edit: The extension is the thing that changes from .jpg to .jpeg when I go view the uploaded image. This is a problem because the website that I need this link for, requires that the image be jpg or png or another format on their list but jpeg is not one of those formats on that list.

WillyBoy
  • 37
  • 5
  • 2
    jpg and jpeg are the same thing. "jpg" is just a common abbreviation because MS-DOS (and old versions of Windows) didn't allow you to end a filename with ".jpeg". – Samwise Mar 27 '22 at 18:36
  • @Samwise Correct. Plus any time you upload something to a 3rd-party site, you should *expect* there to be modifications, whether resolution, compression, headers, etc. – manassehkatz-Moving 2 Codidact Mar 27 '22 at 18:38
  • Please expand your question on exactly what changes. Is it the file name extension that changes from `.jpg` to `.jpeg`? Also explain why that's a problem. – md2perpe Mar 27 '22 at 18:43
  • the extension is the thing that changes from .jpg to .jpeg when I go view the uploaded image. This is a problem because the website that I need this link for, requires that the image be jpg or png or another format on their list but jpeg is not one of those formats on that list. – WillyBoy Mar 27 '22 at 19:23
  • Well, what if you upload a .png image? That's still allowed, right? I don't think Imgur changes .png to anything else. See also: https://stackoverflow.com/questions/10759117/converting-jpg-images-to-png – Nick ODell Mar 27 '22 at 19:37
  • Are you sure that the website that you need the link for requires the file extension to be `.jpg`? – md2perpe Mar 27 '22 at 19:57
  • @NickODell just tried it and it converts it from png to jpeg for some reason. good idea thow – WillyBoy Mar 27 '22 at 19:58
  • 1
    @md2perpe yes its ebay's api https://developer.ebay.com/DevZone/guides/features-guide/content/Development/pictures-intro.html – WillyBoy Mar 27 '22 at 19:59
  • It only says "Images must be in JPG, BMP, GIF, TIF, or PNG format." It doesn't say that the file extension must be `.jpg`. – md2perpe Mar 27 '22 at 20:16
  • @md2perpe right and i tried other format but Imgur converts them to jpeg – WillyBoy Mar 27 '22 at 20:23
  • How big are the files that are converted to JPEG? https://imgur.userecho.com/en/communities/1/topics/107-png-file-changes-to-jpg-when-uploaded – md2perpe Mar 27 '22 at 20:44
  • @md2perpe its at 875KB – WillyBoy Mar 27 '22 at 20:57
  • 1
    As you can read in the link I gave, Imgur sometimes converts files to JPEG. If you do not like it, find some other place to store your images. Or does Ebay require the image to be stored on Imgur? – md2perpe Mar 27 '22 at 21:00

0 Answers0