image-processing

python
import cv2

image = cv2.imread('receipt.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
thresholded = cv2.adaptiveThreshold(

OpenCV image preprocessing for OCR and vision pipelines

opencv image-processing computer-vision
by Dr. Elena Vasquez 1 tab
javascript
const sharp = require('sharp');

const DEFAULTS = {
  maxWidth: 1600,
  maxHeight: 1600,
  format: 'webp',

Resize and Compress Uploaded Images with Sharp Before Saving to Disk

nodejs express sharp
by codesnips 3 tabs
typescript
import sharp from 'sharp';

export interface Variant {
  name: string;
  width: number;
  quality: number;

Generate WebP Image Thumbnails on Upload with Sharp and Express

express sharp image-processing
by codesnips 3 tabs
php
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

Resize and Store User Avatars with Intervention Image in Laravel

laravel file-upload image-processing
by codesnips 3 tabs
python
import io
import os
from uuid import uuid4
from PIL import Image, UnidentifiedImageError

ALLOWED_FORMATS = {"JPEG", "PNG", "WEBP"}

Validate and Generate Image Thumbnails on a Flask Upload Endpoint With Pillow

flask pillow image-processing
by codesnips 3 tabs
php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Polymorphic Media Attachments in Laravel With a Queued Image Resize Job

laravel polymorphism eloquent
by codesnips 4 tabs
ruby
class User < ApplicationRecord
  has_one_attached :avatar do |attachable|
    attachable.variant :thumb,
      resize_to_limit: [256, 256],
      convert: :webp,
      saver: { quality: 80 }

Attach and Resize an Avatar with an Active Storage Variant in Rails

rails active-storage image-processing
by codesnips 3 tabs
javascript
const multer = require('multer');

const ALLOWED_MIME = new Set(['image/jpeg', 'image/png', 'image/webp']);

function fileFilter(req, file, cb) {
  if (!ALLOWED_MIME.has(file.mimetype)) {

Upload and Resize User Avatars with Multer and Sharp in Express

express multer sharp
by codesnips 3 tabs