Coder Social home page Coder Social logo

qoi's People

Contributors

0xflotus avatar gudnimg avatar jxtps avatar kodonnell avatar synodriver avatar yordiverbeeck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

qoi's Issues

Can't build the qoi package with Python 3.12

Note numpy 1.26 is needed with Python 3.12 because distutils is removed.

Building wheels for collected packages: qoi
  Building wheel for qoi (pyproject.toml): started
  Building wheel for qoi (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error

  Building wheel for qoi (pyproject.toml) did not run successfully.
  exit code: 1

  [50 lines of output]
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-cpython-312
  creating build\lib.win-amd64-cpython-312\qoi
  copying src\qoi\benchmark.py -> build\lib.win-amd64-cpython-312\qoi
  copying src\qoi\_version.py -> build\lib.win-amd64-cpython-312\qoi
  copying src\qoi\__init__.py -> build\lib.win-amd64-cpython-312\qoi
  copying src\qoi\qoi.pxd -> build\lib.win-amd64-cpython-312\qoi
  running build_ext
  building 'qoi.qoi' extension
  creating build\temp.win-amd64-cpython-312
  creating build\temp.win-amd64-cpython-312\Release
  creating build\temp.win-amd64-cpython-312\Release\src
  creating build\temp.win-amd64-cpython-312\Release\src\qoi
  "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DQOI_MALLOC=PyMem_Malloc -DQOI_FREE=PyMem_Free -IC:\Users\Gudni\AppData\Local\Temp\pip-build-env-c92eykgi\overlay\Lib\site-packages\numpy\core\include -ID:\Prusa-Firmware-Buddy-Private\.venv\include -IC:\Users\Gudni\AppData\Local\Programs\Python\Python312\include -IC:\Users\Gudni\AppData\Local\Programs\Python\Python312\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" /Tcsrc/qoi/implementation.c /Fobuild\temp.win-amd64-cpython-312\Release\src/qoi/implementation.obj
  implementation.c
  C:\Users\Gudni\AppData\Local\Temp\pip-install-y6f4ym_p\qoi_7194dc5fc5904c6d98e093ad731ed32d\src\qoi\phoboslab_qoi/qoi.h(597): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Users\Gudni\AppData\Local\Temp\pip-install-y6f4ym_p\qoi_7194dc5fc5904c6d98e093ad731ed32d\src\qoi\phoboslab_qoi/qoi.h(641): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
  C:\Users\Gudni\AppData\Local\Temp\pip-install-y6f4ym_p\qoi_7194dc5fc5904c6d98e093ad731ed32d\src\qoi\phoboslab_qoi/qoi.h(619): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DQOI_MALLOC=PyMem_Malloc -DQOI_FREE=PyMem_Free -IC:\Users\Gudni\AppData\Local\Temp\pip-build-env-c92eykgi\overlay\Lib\site-packages\numpy\core\include -ID:\Prusa-Firmware-Buddy-Private\.venv\include -IC:\Users\Gudni\AppData\Local\Programs\Python\Python312\include -IC:\Users\Gudni\AppData\Local\Programs\Python\Python312\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" /Tcsrc/qoi/qoi.c /Fobuild\temp.win-amd64-cpython-312\Release\src/qoi/qoi.obj
  qoi.c
  C:\Users\Gudni\AppData\Local\Temp\pip-build-env-c92eykgi\overlay\Lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
  src/qoi/qoi.c(13239): warning C4996: 'Py_OptimizeFlag': deprecated in 3.12
  src/qoi/qoi.c(21985): error C2039: 'curexc_traceback': is not a member of '_ts'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/pystate.h(115): note: see declaration of '_ts'
  src/qoi/qoi.c(21988): error C2039: 'curexc_traceback': is not a member of '_ts'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/pystate.h(115): note: see declaration of '_ts'
  src/qoi/qoi.c(23336): error C2039: 'ob_digit': is not a member of '_longobject'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
  src/qoi/qoi.c(24904): error C2039: 'ob_digit': is not a member of '_longobject'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
  src/qoi/qoi.c(24959): error C2039: 'ob_digit': is not a member of '_longobject'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
  src/qoi/qoi.c(25100): error C2039: 'ob_digit': is not a member of '_longobject'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
  src/qoi/qoi.c(25155): error C2039: 'ob_digit': is not a member of '_longobject'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
  src/qoi/qoi.c(25296): error C2039: 'ob_digit': is not a member of '_longobject'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
  src/qoi/qoi.c(25351): error C2039: 'ob_digit': is not a member of '_longobject'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
  src/qoi/qoi.c(25530): error C2039: 'ob_digit': is not a member of '_longobject'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
  src/qoi/qoi.c(25585): error C2039: 'ob_digit': is not a member of '_longobject'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
  src/qoi/qoi.c(25936): error C2039: 'ob_digit': is not a member of '_longobject'
  C:\Users\Gudni\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for qoi
Failed to build qoi
ERROR: Could not build wheels for qoi, which is required to install pyproject.toml-based projects

Read only ndarray is not permitted while writing it to a file

To reproduce:

import qoi
from PIL import Image
image_filepath = "something.png"
prepared_image_filepath = "something.qoi"
image = Image.open(image_filepath).convert('RGB')
image_qoi = np.asarray(image)
_ = qoi.write(prepared_image_filepath, image_qoi)

Output:

Traceback (most recent call last):
...
  File "main.py", line 452, in __init__
    _ = qoi.write(prepared_image_filepath, image_qoi)
  File "src/qoi/qoi.pyx", line 31, in qoi.qoi.write
  File "<stringsource>", line 663, in View.MemoryView.memoryview_cwrapper
  File "<stringsource>", line 353, in View.MemoryView.memoryview.__cinit__
ValueError: buffer source array is read-only

Version:

Python 3.10.13
numpy                        1.26.4
qoi                          0.5.0

Input format

Hello! Thank you for your library. Can you please clarify in the README about input shape? I assume it is (height, width, channels), where height and width is limited up to 400000000 pixels total (h*w) (link), and channels are either 3 or 4 dimension of RGBA (link).

Fails to install on Mac OS with Apple M1

Hello,

Currently the library fails to install on Mac OS with Apple M1 Silicon, because of the numpy dependency. This is due to the (outdated) versions of numpy in pyproject.toml file. I managed to install from source by changing the contents of the file (adding "numpy>=1.24.2" in the requires section of pyproject.toml).

Could you please bump the version of numpy to fix this issue?

Incompatibility with `numpy` 2.0.0 -> error on import

Importing QOI package while having Numpy 2.0.0 installed causes this error:

Traceback (most recent call last):
  File "D:\...\MultiScaler-Plus\src\standalone.py", line 14, in <module>
    import qoi
  File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\qoi\__init__.py", line 2, in <module>
    from qoi.qoi import QOIColorSpace, decode, encode, read, write
  File "src/qoi/qoi.pyx", line 1, in init qoi.qoi
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Import Fails on M1 Mac (Apple Silicon)

The package will install on an M1 Mac (Apple Silicon) with pip but importing raises the following exception:

Python 3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:24:38) 
[Clang 12.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import qoi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/john/miniforge3/envs/test-qoi/lib/python3.9/site-packages/qoi/__init__.py", line 2, in <module>
    from qoi.qoi import QOIColorSpace, decode, encode, read, write
  File "src/qoi/qoi.pyx", line 1, in init qoi.qoi
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

The package appears to work just fine on other systems. I am using numpy version 1.21.6 on an M1 MacBook air to produce this error.

qoi.read(path, 3) returns 4 channel array ending in heap trash for 4 channel image

https://github.com/kodonnell/qoi/blob/main/src/qoi/qoi.pyx#L80 currently reads:

return PixelWrapper().as_ndarray(desc.height, desc.width, desc.channels, pixels)

ignoring the passed in channel parameter.

This is correct behavior when channel==0 (the default), but not when it's 3 for a 4 channel image (you end up with heap trash), or when a 4 is passed in for a 3 channel image (you end up with a cropped array).

Something along the lines of

return PixelWrapper().as_ndarray(desc.height, desc.width, desc.channels if channels == 0 else channels, pixels)

should fix it.

Thanks!

Distribute wheels on PyPI

Hi. Thanks for this project!

I see you are only distributing a "source distribution" on PyPI which contains the C files that needs to be compiled. This means you have to have a C compiler on your machine in order for installation to work (not always the case on Windows), and generally may complicate the installation.

Python wheels are a great way to distribute precompiled Python C extensions. Can you consider uploading wheels to PyPI?

There are several projects that can help you automate the creation of wheels for different platforms, see cbuildwheel for example.

Approximate with GraphicsMagick and/or G'MIC

I wonder whether the current code could be rewritten (approximated?) using GraphicsMagick and/or G'MIC without any Python nor any otther dependencies to make it accessible from shell without any further dependencies.

I think we can assume gm and gmic will both soon support QOI (both decode & encode). So let's take it for granted.

Then the only question is whether it's worth rewriting (or approximating) the sampling only using what gm/gmic/both offer in command line is possible?

Thoughts?

qoi-0.2.0: ModuleNotFoundError: No module named 'numpy'

I'm trying to install qoi when building a docker image on ubuntu 20.04, but get the following:

Step 3/3 : RUN pip install --no-cache-dir       numpy   qoi     opencv-python   scikit-image    pillow  torchvision     hdf5storage     ninja   timm    pgmagick        tensorboard     matplotlib
 ---> Running in 9edd47a3e8be
Requirement already satisfied: numpy in /opt/conda/lib/python3.7/site-packages (1.21.5)
Collecting qoi
  Downloading qoi-0.2.0.tar.gz (3.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 19.7 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      Traceback (most recent call last):
        File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/opt/conda/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-_t96qhcs/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-_t96qhcs/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-_t96qhcs/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 335, in run_setup
          exec(code, locals())
        File "<string>", line 3, in <module>
      ModuleNotFoundError: No module named 'numpy'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
The command '/bin/sh -c pip install --no-cache-dir      numpy   qoi     opencv-python   scikit-image    pillow  torchvision     hdf5storage     ninja   timm    pgmagick        tensorboard     matplotlib' returned a non-zero code: 1

So numpy is installed, but the qoi installer fails to find it I guess?

This also happens with v0.1.2, but not with v0.1.1.

Lightly edited Dockerfile (removing some slow and unrelated dependencies):

FROM pytorch/pytorch:1.12.1-cuda11.3-cudnn8-runtime

# Always run apt-get update and install in a single line, or it runs into caching issues
RUN apt-get update && apt-get install -y \
	ffmpeg \
	libsm6 \
	libxext6

# I tried pip requirements file but it didn't immediately work, so just switched to listing the packages
RUN pip install --no-cache-dir \
	numpy \
	qoi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.