Code Explainers

Code explainers tagged #image-processing

python
from collections import Counter
 
import numpy as np
from PIL import Image

Extracting a color palette with K-means

clustering image-processing kmeans
Intermediate 7 steps
go
func ServeThumbnail(c *gin.Context) {
	raw := c.Param("token")
	sig := c.Query("sig")
 

A signed thumbnail endpoint in Gin

signed-urls image-processing http-handler
Intermediate 9 steps
python
import os
from uuid import uuid4
 
from flask import Blueprint, current_app, jsonify, request, url_for

How a Flask image upload endpoint works

file-upload validation image-processing
Intermediate 9 steps
ruby
class ImageNormalizer
  ORIENTATION_TRANSFORMS = {
    1 => ->(img) {},
    2 => ->(img) { img.flop },

Correcting EXIF orientation in Ruby

lookup-table lambdas image-processing
Intermediate 7 steps
javascript
export async function compressImage(file, { maxWidth = 1600, maxHeight = 1600, quality = 0.8, mimeType = 'image/jpeg' } = {}) {
  const bitmap = await createImageBitmap(file);
 
  let { width, height } = bitmap;

Compressing images in the browser with canvas

canvas image-processing promises
Intermediate 7 steps
php
<?php
 
namespace App\Services;
 

Batch image resizing with PHP GD

image-processing constructor-promotion match-expression
Intermediate 10 steps
python
from pathlib import Path
 
from PIL import Image, ImageOps
 

Batch image resizing with Pillow

image-processing batch-jobs error-handling
Intermediate 8 steps
php
<?php
 
namespace App\Http\Controllers;
 

Handling avatar uploads in Laravel

file-upload image-processing validation
Intermediate 8 steps