Goodbye, 6GB Photoshop: How AI Clones and a Python Pipeline Cut 3 Hours of Routine Down to 10 Minutes

2026-11-17来源 dev.toEnglish
Goodbye, 6GB Photoshop: How AI Clones and a Python Pipeline Cut 3 Hours of Routine Down to 10 Minutes

Lately, an interesting trend has emerged in the software development world: enthusiasts are using AI and vibe-coding to rewrite popular software suites from scratch—particularly heavyweight Adobe products like Photoshop and After Effects. I’ve already tested some of these open-source alternatives in practice (such as Photocraft), and in a head-to-head comparison, classic Photoshop is starting to lose serious ground to its lightweight counterparts.

Judge for yourself: modern Photoshop’s installer has already blown past 6 gigabytes, while the subscription price becomes less and less budget-friendly. Yet for the vast majority of users, that massive feature set is completely excessive. An open-source clone is dozens of times smaller, entirely free, handles all core tasks, and—best of all—mirrors the familiar interface almost one-to-one, making the transition completely painless. Of course, it’s still too early for professional retouchers and designers to abandon the Adobe ecosystem altogether, but this trend is definitely worth keeping an eye on.

In my own daily workflow, however, I went even further. I realized that out of Photoshop’s entire arsenal, I was using maybe ten tools at most—and mostly for repetitive, monotonous tasks that ate up half of my workday. Whenever a new part comes off the production line, it needs to be photographed from six angles, stripped of shadows and glare, cleared of its background, carefully cut out inside every technical hole, centered perfectly in the frame, and then recolored into five different color variations. That produces 30 ready-to-publish e-commerce product images, yet doing it manually used to burn 2 to 3 hours every single day.

Eventually, I simply ditched manual work in a graphic editor and moved the entire pipeline over to Python using OpenCV, Pillow, NumPy, rembg, and PyQt6.

Under the Hood: How the Pipeline Works

The workflow is split into two stages: a primary cleanup and geometry script, followed by a batch recoloring utility (color.py) that can run either as a PyQt6 GUI (for dialing in colors with sliders) or in a completely console-based headless mode driven by JSON configs.

1. Pre-Processing for Background Removal & Technical Holes

The biggest headache when photographing plastic or metal parts is tiny specular highlights and internal mounting holes, where standard background-removal models often trip up. Before feeding an image into rembg (I chose the isnet-general-use model because it handles fine internal holes noticeably better), the frame goes through a median filter, glare suppression, and adaptive contrast enhancement in the YCbCr color space:

# Using isnet-general-use — it handles internal part holes much better session = new_session(model_name="isnet-general-use") def advanced_cleaning(img): """Strip out micro-glare 'sand' and tone down harsh specular highlights""" img_smooth = img.filter(ImageFilter.MedianFilter(size=3)) gray = img_smooth.convert('L') glare_mask = gray.point(lambda x: 255 if x > 200 else 0, '1') glare_mask = glare_mask.convert('L').filter(ImageFilter.GaussianBlur(radius=5)) lut = [int(x * 0.8) if x > 180 else x for x in range(256)] img_no_glare = img_smooth.point(lut * 3) return Image.composite(img_no_glare, img_smooth, glare_mask) def apply_adaptive_contrast(img): """Boost contrast strictly on the luminance (Y) channel for cleaner masks""" img_ycbcr = img.convert('YCbCr') y, cb, cr = img_ycbcr.split() y = ImageOps.autocontrast(y, cutoff=2) img_enhanced = Image.merge('YCbCr', (y, cb, cr)).convert('RGB') return ImageEnhance.Sharpness(img_enhanced).enhance(1.5) 

2. Smart Horizon Leveling & Auto-Centering with OpenCV

Once the alpha channel is extracted, the script detects the outer contour of the part (cv2.findContours), calculates its minimum bounding rectangle (cv2.minAreaRect), and—if the horizon tilt is within 15 degrees—automatically levels the object, scales it to fill 90% of the frame, and centers it on the canvas.

At this stage, the script outputs two sets of files: transparent RGBA PNGs for automated recoloring and RGB images on a pure white background. I then do a quick visual sanity check—if the algorithm misjudges a tricky piece of geometry, I rapidly touch up the mask and hit Y in the console to trigger batch coloring.

3. Recoloring via LUTs While Preserving Shadows and Texture

The most satisfying step is generating all 5 color variations. Simply flooding a part with a flat color ruins its depth and surface grain. Instead, I convert the image to grayscale and map it through a 256-entry Lookup Table (LUT) where shadows, midtones, and highlights are interpolated independently:

def apply_transformation(img, params): """Recolor the part via a custom LUT while keeping surface texture, shadows, and highlights""" gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) _, mask = cv2.threshold(gray, 248, 255, cv2.THRESH_BINARY_INV) mask_3d = cv2.merge([cv2.GaussianBlur(mask, (5, 5), 0).astype(float) / 255.0] * 3) lut = np.zeros((256, 1, 3), dtype=np.uint8) target = np.array(params.get("target_color_bgr", [10, 10, 255])) h_color = np.array(params.get("highlight_color_bgr", [255, 255, 255])) shadow = (target * (params.get("shadow_intensity", 100) / 255.0)).astype(np.uint8) h_sat = params.get("highlight_sat", 70) / 100.0 s_end = params.get("shadow_end", 20) / 100.0 m_end = params.get("main_end", 85) / 100.0 for i in range(256): p = i / 255.0 if p < s_end: color = shadow * (p / s_end) elif p < m_end: color = shadow + (target - shadow) * ((p - s_end) / (m_end - s_end)) else: ratio = (p - m_end) / (1.0 - m_end) end_p = h_color * h_sat + np.array([255, 255, 255]) * (1.0 - h_sat) color = target + (end_p - target) * ratio lut[i, 0] = color br, ct = params.get("brightness", 13), params.get("contrast", 11) detail = cv2.applyColorMap(cv2.convertScaleAbs(gray, alpha=br/10.0, beta=5), lut) res = (detail * mask_3d + np.full_like(img, params.get("bg_color_bgr", [255, 255, 255])) * (1 - mask_3d)).astype(np.uint8) return cv2.convertScaleAbs(res, alpha=ct/10.0, beta=0) 

Original raw photo of the 3D-printed part with background and shadows

Background removed and centered part

color variations generated automatically via Python LUTs

color variations generated automatically via Python LUTs

If a new filament or material color gets added to the catalog tomorrow, I just save a single JSON preset in the GUI editor—and regenerating every angle takes 10 seconds at most. The routine that used to swallow half my workday now takes literally 10 minutes, leaving 30 upload-ready product photos on my desk.

Why This Only Became Practical Now

Of course, this kind of automation was technically possible before the AI era, but building this pipeline from scratch would have taken at least a couple of months. Hiring outside developers or outsourcing it would have been far too expensive—practically out of reach for a small business. The reason is straightforward: you would have had to learn the nuances of OpenCV, Pillow, rembg, and PyQt6 from the ground up, and even before that, figure out which segmentation models and color spaces fit the problem best.

Today, with the help of AI (such as Gemini, which I use most often), you can quickly draft a technical specification, choose the right libraries, configure the environment, write the code, and debug edge cases rapidly. The savings in time and engineering effort are massive.

This story is yet another confirmation that the era of bloated all-in-one software giants is giving way to targeted, lightweight tools and scripts tailored strictly to your specific workflow.

What is your setup with graphic editors and repetitive media processing these days? Are you still paying for heavyweight suites just for a handful of basic features, or have you already switched to lightweight open-source alternatives and custom scripts? Let’s discuss in the comments!

原文:https://www.a8q9.cn/en/article/goodbye-6gb-photoshop-how-ai-clones-and-a-python-pipeline-cut-3-hours-of-routine-b76010.html

相关文章