How to skip PNG transparent images?
cristianstan opened this issue · comments
Congratulations for this nice project!
I just tested it out. It works smoothly but I have a problem. I need to placehold all images type but excluding the PNG's image format.
Is this possible? If yes how can I achieve this because I wasn't able to find this on the readme section.
Looking forward to your reply,
- Cristian
Hi, Cristian!
Check for last version of PlaceHoldMachine, it's 1.0.2 now.
Method set_allowed_image_formats was added and can be used to solve your issue.
# -*- coding: utf-8 -*-
from PlaceHoldMachine import PlaceHoldMachine
i = PlaceHoldMachine()
i.log_level = 2
i.allowed_image_formats(['JPEG'])
dirs = [
'C:/Users/admin/Pictures/test/MediaTrans'
]
i.walk_recursive(dirs)
i.start()
p.s. Don't forget to install latest Pillow with pip install Pillow
That's perfect! Thank you for the fast reply!
Keep up the good work 👍
I just downloaded the latest version of PlaceHoldMachine.py but when I run the command I get this error:
Traceback (most recent call last):
File "simple.py", line 8, in <module>
i.allowed_image_formats(['JPEG'])
TypeError: 'str' object is not callable
In simple.py I added the line (So the error comes from this line):
i.allowed_image_formats(['JPEG'])
How can I solve this error? Changing the '*' with 'JPEG' in PlaceHoldMachine.py solves the trick but I'm just curious why it gives me that error?
Any advice?
Running this code on Python 3.6.0 and Python 2.7.13
# -*- coding: utf-8 -*-
from PlaceHoldMachine import PlaceHoldMachine #import class
i = PlaceHoldMachine() #create class instance
i.log_level = 2 #set log level to 2, so we can see errors
# set directories list, where all images will be replaced with placeholders
dirs = [
'C:/Users/admin/Pictures/test/MediaTrans'
]
i.allowed_image_formats(['JPEG'])
i.walk_recursive(dirs) #recursively find all images in given directories
i.start() #begin conversion process
Everything works fine.
Can you provide full invalid source code?
Still same problem.
- simple.py file contains now the same content provided in your last reply.
# -*- coding: utf-8 -*-
from PlaceHoldMachine import PlaceHoldMachine #import class
i = PlaceHoldMachine() #create class instance
i.log_level = 2 #set log level to 2, so we can see errors
# set directories list, where all images will be replaced with placeholders
dirs = [
'C:/Users/CSTAR-PC/Desktop/Dummy_GEN'
]
i.allowed_image_formats(['JPEG'])
i.walk_recursive(dirs) #recursively find all images in given directories
i.start() #begin conversion process
Note: I'm using Python v2.7