{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# *pyvips* – Image processing with libvips\n\n[Python wrapper](https://libvips.github.io/pyvips/) for libvips is a demand-driven, horizontally threaded image processing library. Compared to similar libraries, libvips runs quickly and uses little memory.\n\nIt has around 300 operations covering arithmetic, histograms, convolution, morphological operations, frequency filtering, colour, resampling, statistics and others. It supports a large range of numeric formats, from 8-bit int to 128-bit complex. Images can have any number of bands. It supports a good range of image formats, including JPEG, TIFF, PNG, WebP, FITS, Matlab, OpenEXR, PDF, SVG, HDR, PPM, CSV, GIF, Analyze, NIfTI, DeepZoom, and OpenSlide. It can also load images via ImageMagick or GraphicsMagick, letting it load formats like DICOM.","metadata":{}},{"cell_type":"markdown","source":"## Download the lib & pip package","metadata":{}},{"cell_type":"code","source":"!apt -y -q update\n#!apt -y -q upgrade","metadata":{"_kg_hide-input":false,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2023-10-23T15:03:21.938080Z","iopub.execute_input":"2023-10-23T15:03:21.939078Z","iopub.status.idle":"2023-10-23T15:03:29.584888Z","shell.execute_reply.started":"2023-10-23T15:03:21.939001Z","shell.execute_reply":"2023-10-23T15:03:29.583332Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### dowanlod the deb packages","metadata":{}},{"cell_type":"code","source":"!mkdir -p linux_packages\n!apt -y install -d -o=dir::cache=/kaggle/working/linux_packages \\\n    libvips libvips-dev libvips-tools","metadata":{"_kg_hide-input":false,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2023-10-23T15:03:29.588156Z","iopub.execute_input":"2023-10-23T15:03:29.588701Z","iopub.status.idle":"2023-10-23T15:04:26.200722Z","shell.execute_reply.started":"2023-10-23T15:03:29.588647Z","shell.execute_reply":"2023-10-23T15:04:26.199140Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# set Yes as reply to all with non-interactive install\n#!yes | dpkg --install --force-depends ./linux_packages/archives/*.deb","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2023-10-23T15:04:26.203114Z","iopub.execute_input":"2023-10-23T15:04:26.203530Z","iopub.status.idle":"2023-10-23T15:04:26.209536Z","shell.execute_reply.started":"2023-10-23T15:04:26.203492Z","shell.execute_reply":"2023-10-23T15:04:26.207898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### compile the pyVips form source","metadata":{}},{"cell_type":"code","source":"!mkdir -p python_packages\n!pip wheel https://github.com/libvips/pyvips/archive/refs/heads/master.zip --wheel-dir=\"python_packages/\"\n!ls -lh python_packages/","metadata":{"_kg_hide-input":false,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2023-10-23T15:04:26.213170Z","iopub.execute_input":"2023-10-23T15:04:26.213857Z","iopub.status.idle":"2023-10-23T15:04:39.122475Z","shell.execute_reply.started":"2023-10-23T15:04:26.213804Z","shell.execute_reply":"2023-10-23T15:04:39.120894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## How to install this package\n\n1. Click \"**Add Data**\" on your own notebook\n2. Search for \"**Pip📦pkg: pyvips (download 4 offline)**\" and add this notebook as a data source OR add the build dataset **pyVips: python & deb package**\n3. Run those instalation lines bellow with replacing `XXX_packages/` by `/kaggle/input/pyvips-python-and-deb-package/XXX_packages/`\n\n### Installing the downloaded version","metadata":{}},{"cell_type":"code","source":"# set Yes as reply to all with non-interactive install\n!yes | dpkg -i --force-depends ./linux_packages/archives/*.deb\n!pip install pyvips -f python_packages/ --no-index","metadata":{"_kg_hide-input":false,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2023-10-23T15:04:39.124430Z","iopub.execute_input":"2023-10-23T15:04:39.124929Z","iopub.status.idle":"2023-10-23T15:06:05.839897Z","shell.execute_reply.started":"2023-10-23T15:04:39.124888Z","shell.execute_reply":"2023-10-23T15:06:05.838285Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip list | grep pyvips","metadata":{"execution":{"iopub.status.busy":"2023-10-23T15:06:05.842399Z","iopub.execute_input":"2023-10-23T15:06:05.842979Z","iopub.status.idle":"2023-10-23T15:06:09.277883Z","shell.execute_reply.started":"2023-10-23T15:06:05.842928Z","shell.execute_reply":"2023-10-23T15:06:09.276306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pyvips\npyvips.__version__","metadata":{"execution":{"iopub.status.busy":"2023-10-23T15:06:09.279917Z","iopub.execute_input":"2023-10-23T15:06:09.280351Z","iopub.status.idle":"2023-10-23T15:06:09.711476Z","shell.execute_reply.started":"2023-10-23T15:06:09.280301Z","shell.execute_reply":"2023-10-23T15:06:09.709865Z"},"trusted":true},"execution_count":null,"outputs":[]}]}