-
Notifications
You must be signed in to change notification settings - Fork 17
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
vtf :jpg_to_vtf .I need some example #16
Comments
You'll need from PIL import Image
from srctools.vtf import VTF, ImageFormats
# Specify the format here to convert to when saving.
vtf = VTF(1024, 1024, fmt=ImageFormats.DXT1)
img = Image.open('C:\\Users\\73580\\Desktop\\R.jpg')
largest_frame = vtf.get() # This retrieves the first frame with the largest mipmap size.
# Copy into the frame, the format here is what PIL uses for non-transparent images. You'd want ImageFormats.RGBA8888 for transparent ones.
largest_frame.copy_from(img.tobytes(), ImageFormats.RGB888)
with open('C:\\Users\\73580\\Desktop\\file.vtf', 'wb') as f:
vtf.save(f) |
I'm sorry I still have some problems.
What is the problem with the size of the picture? |
I realized my mistake because the image needs RGBA8888, and the size of direct zoom is blank. However, I found that after such modification, the generated vtf file could not load images in L4D2 painting.My own guess may be the following reasons.
|
You don't need to assign the frame no, |
I got it,this is true. |
personally to convert images into vtfs I use this: https://rafradek.github.io/Mishcatt/ |
Perhaps I messed up something in the C extension. Try adding the following to your script before the import sys
sys.modules["srctools._cy_vtf_readwrite"] = None |
I think these may be necessary because when I try to write
The error type is NotImplementedError
|
Oh right, you'll need to change the |
I want to convert a jpg image into a vtf file, but I don't know where the problem is. The file is wrong
The text was updated successfully, but these errors were encountered: