fehlfarbe / gimp2acv

Converts GIMP curves to Adobe ACV curves
7 stars 3 forks source link

After converting gimp2acv.py to python3 and manually correcting a few string-related TypeErrors, got .acv file of 4 bytes #1

Closed PacoH closed 8 months ago

PacoH commented 9 months ago

File had to be opened with a hex editor and all it contained was 00040000 in hex. uploads for issues.zip

UPDATE I found what I did wrong. I converted only gimp2acv.py. This time I converted the entire 'gimp2acv-master' directory.

2to3 -v --no-diffs -w "gimp2acv-master"

RefactoringTool: ...
RefactoringTool: gimp2acv.py
RefactoringTool: read_acv.py
RefactoringTool: acv.py

I still got errors when I ran the converted version.

python3 ./gimp2acv.py -i GIMPcurves.gcv -o GIMPcurves.acv
Traceback (most recent call last):
  File "gimp2acv-master/./gimp2acv.py", line 99, in <module>
    if is_old_format(f):
       ^^^^^^^^^^^^^^^^
  File "gimp2acv-master/./gimp2acv.py", line 16, in is_old_format
    if line.startswith("# GIMP Curves File"):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

Traceback (most recent call last):
  File "gimp2acv-master/./gimp2acv.py", line 104, in <module>
    curve = convert_new_format(f)
            ^^^^^^^^^^^^^^^^^^^^^
  File "gimp2acv-master/./gimp2acv.py", line 24, in convert_new_format
    l = l.lstrip().replace(')', '').replace('\n', '')
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: a bytes-like object is required, not 'str'

Both these errors are due to the input text object, GIMPcurves.gcv, being opened in byte format on line 98:

with open(input, 'rb') as f

The simple fix is to open the input as text:

with open(input, 'r') as f

Now it works 100% and the output acv file is completely valid.

python3 ./gimp2acv.py -i GIMPcurves.gcv -o GIMPcurves.acv

I tested it with ffmpeg -i "input.jpg" -vf "curves=psfile=GIMPcurves.acv" "output.jpg" and got the expected output.

I uploaded the converted version:

gimp2acv-master - python3.zip

fehlfarbe commented 8 months ago

Hey thanks for the reminder and your code. The repo was quite outdated so I refactored it and added Python 3 support :)

PacoH commented 8 months ago

Thanks. This is a valuable resource for those of us who don't have PhotoShop but want to use GIMP curves files with ffmpeg's curves=psfile='curves.acv'.

I just tried it and got error:

gimp2acv.py", line 25, in <module>
    outputFile = options.outputFile
                 ^^^^^^^^^^^^^^^^^^
AttributeError: 'Values' object has no attribute 'outputFile'

OK, I found the problem in line 25:

outputFile = options.outputFile should be outputFile = options.output.