Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to skip PNG transparent images? #3

Open
cristianstan opened this issue May 5, 2017 · 5 comments
Open

How to skip PNG transparent images? #3

cristianstan opened this issue May 5, 2017 · 5 comments

Comments

@cristianstan
Copy link

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
@Priler
Copy link
Owner

Priler commented May 5, 2017

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

@Priler Priler closed this as completed May 5, 2017
@cristianstan
Copy link
Author

That's perfect! Thank you for the fast reply!

Keep up the good work 👍

@cristianstan
Copy link
Author

cristianstan commented May 5, 2017

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?

@Priler
Copy link
Owner

Priler commented May 5, 2017

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?

@Priler Priler reopened this May 5, 2017
@cristianstan
Copy link
Author

cristianstan commented May 5, 2017

Still same problem.

  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants