-2

I have used the below code to

enter image description hereconvert JPG into PNG file:

But when i am running this code from the command line terminal using: python a.py "C:\Users\nishant.gupta2\PycharmProjects\jpgtopngconverter\photo" new

The system is giving me the error:

 PermissionError: [Errno 13] Permission denied: 'C:\\Users\\nishant.gupta2\\PycharmProjects\\jpgtopngconverter\\photo'

My code is below:

import sys
import os
from PIL import Image

image_folder=sys.argv[1]

output_folder=sys.argv[2]

if not os.path.exists(output_folder):
    os.mkdir(output_folder)


for items in os.listdir(image_folder):

    im= Image.open(f'{image_folder}')
    im.save(f'{output_folder}.png','png')
nishant gupta
  • 15
  • 1
  • 4
  • What is the issue, exactly? What do/don't you understand from that error message? – AMC Feb 15 '20 at 03:09

2 Answers2

0

It looks like this has to do with file permissions rather than your code. Your code is running under a separate user than the image folder you are specifying, depending on admin status you may get permission issues.

lincolnck
  • 302
  • 1
  • 12
0

You are trying to open a folder here :

im= Image.open(f'{image_folder}')

rather then image. You should specify the path of image.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Yeshwanth N
  • 570
  • 4
  • 15