Skip to content

Image Processing

Resize, crop, compress, convert, OCR, QR codes, and watermarks.

9 modules

ModuleDescription
Nén hình ảnhNén hình ảnh để giảm kích thước tệp trong khi duy trì chất lượng
Chuyển đổi hình ảnhChuyển đổi hình ảnh sang định dạng khác (PNG, JPEG, WEBP, v.v.)
Cắt ẢnhCắt hình ảnh theo tọa độ chỉ định
Tải hình ảnhTải hình ảnh từ URL về tệp cục bộ
Trích Xuất Văn Bản OCRTrích xuất văn bản từ hình ảnh bằng OCR
Tạo mã QRTạo mã QR từ văn bản, URL hoặc dữ liệu
Thay đổi kích thước hình ảnhThay đổi kích thước hình ảnh theo kích thước chỉ định với các thuật toán khác nhau
Xoay ẢnhXoay hình ảnh theo độ chỉ định
Thêm WatermarkThêm watermark văn bản hoặc hình ảnh vào ảnh

Modules

Nén hình ảnh

image.compress

Nén hình ảnh để giảm kích thước tệp trong khi duy trì chất lượng

Parameters:

NameTypeRequiredDefaultDescription
input_pathstringYes-Path to the input image file
output_pathstringNo-Path where the processed image will be saved
qualitynumberNo85Quality level (1-100, higher is better)
optimizebooleanNoTrueApply additional optimization
max_size_kbnumberNo-Target maximum file size in KB
formatselect (png, jpeg, webp, gif, bmp, tiff)NopngOutput image format

Output:

FieldTypeDescription
output_pathstringĐường dẫn đến hình ảnh đã nén
original_size_bytesnumberĐường dẫn đến hình ảnh đã nén
compressed_size_bytesnumberKích thước tệp gốc tính bằng byte
compression_rationumberKích thước tệp đã nén tính bằng byte

Example: Compress with quality setting

yaml
input_path: /path/to/image.jpg
quality: 75

Example: Compress to target size

yaml
input_path: /path/to/image.png
max_size_kb: 500

Chuyển đổi hình ảnh

image.convert

Chuyển đổi hình ảnh sang định dạng khác (PNG, JPEG, WEBP, v.v.)

Parameters:

NameTypeRequiredDefaultDescription
input_pathstringYes-Path to the input image file
output_pathstringNo-Path where the processed image will be saved
formatselect (png, jpeg, webp, gif, bmp, tiff)YespngOutput image format
qualitynumberNo85Quality level (1-100, higher is better)
resizeobjectNo-Resize options:

Output:

FieldTypeDescription
pathstringĐường dẫn đến hình ảnh đã chuyển đổi
sizenumberĐường dẫn đến hình ảnh đã chuyển đổi
formatstringĐường dẫn đến hình ảnh đã chuyển đổi
dimensionsobjectKích thước tệp tính bằng byte

Example: Convert PNG to JPEG

yaml
input_path: /tmp/image.png
format: jpeg
quality: 90

Cắt Ảnh

image.crop

Cắt hình ảnh theo tọa độ chỉ định

Parameters:

NameTypeRequiredDefaultDescription
input_pathstringYes-Đường dẫn đến ảnh đầu vào
output_pathstringYes-Đường dẫn cho ảnh đầu ra
leftnumberYes-Tọa độ trái của vùng cắt
topnumberYes-Tọa độ trên của vùng cắt
rightnumberYes-Tọa độ phải của vùng cắt
bottomnumberYes-Tọa độ dưới của vùng cắt

Output:

FieldTypeDescription
output_pathstringĐường dẫn đến ảnh đã cắt
widthintegerChiều rộng của ảnh đã cắt
heightintegerChiều cao của ảnh đã cắt
original_widthintegerChiều rộng ảnh gốc
original_heightintegerChiều cao ảnh gốc

Example: Crop center region

yaml
input_path: /path/to/image.png
output_path: /path/to/cropped.png
left: 100
top: 100
right: 500
bottom: 400

Tải hình ảnh

image.download

Tải hình ảnh từ URL về tệp cục bộ

Parameters:

NameTypeRequiredDefaultDescription
urlstringYes-URL of the image to download
output_pathstringNo-Path where the processed image will be saved
output_dirstringNo/tmpDirectory where output files will be saved
headersobjectNo{}HTTP request headers as key-value pairs
timeoutnumberNo30Maximum time to wait in seconds

Output:

FieldTypeDescription
pathstringĐường dẫn tệp cục bộ của hình ảnh đã tải
sizenumberĐường dẫn tệp cục bộ của hình ảnh đã tải
content_typestringĐường dẫn tệp cục bộ của hình ảnh đã tải
filenamestringKích thước tệp tính bằng byte

Example: Download image from URL

yaml
url: https://example.com/photo.jpg
output_dir: /tmp/images

Trích Xuất Văn Bản OCR

image.ocr

Trích xuất văn bản từ hình ảnh bằng OCR

Parameters:

NameTypeRequiredDefaultDescription
image_pathstringYes-Đường dẫn đến tệp hình ảnh
languagestringNoengMã ngôn ngữ cho OCR (vd: eng, chi_sim)
psmnumberNo3Chế độ phân đoạn trang của Tesseract
output_typeselect (text, data, boxes)NotextLoại đầu ra OCR (văn bản hoặc dữ liệu)

Output:

FieldTypeDescription
textstringVăn bản trích xuất từ hình ảnh
confidencenumberĐiểm tin cậy của OCR
languagestringNgôn ngữ sử dụng cho OCR

Example: Extract text from image

yaml
image_path: /path/to/document.png
language: eng

Tạo mã QR

image.qrcode_generate

Tạo mã QR từ văn bản, URL hoặc dữ liệu

Parameters:

NameTypeRequiredDefaultDescription
datastringYes-Text, URL, or data to encode
output_pathstringNo-Path where the processed image will be saved
formatselect (png, svg)NopngOutput image format
sizenumberNo300Size in pixels
colorstringNo#000000Color of the QR code (hex or name)
backgroundstringNo#FFFFFFBackground color (hex or name)
error_correctionselect (L, M, Q, H)NoMError correction level
bordernumberNo4Border width in modules (quiet zone)
versionnumberNo-QR code version 1-40 (leave empty for auto-detect)
logo_pathstringNo-Path to logo image to embed in center

Output:

FieldTypeDescription
output_pathstringĐường dẫn đến hình ảnh mã QR đã tạo
file_sizenumberĐường dẫn đến hình ảnh mã QR đã tạo
dimensionsobjectKích thước tệp đầu ra tính bằng byte

Example: Generate URL QR code

yaml
data: https://flyto.dev
output_path: /tmp/flyto_qr.png

Example: Custom styled QR code

yaml
data: Hello World
color: #6366F1
size: 500
error_correction: H

Example: SVG QR code

yaml
data: https://flyto.dev
format: svg
border: 2

Thay đổi kích thước hình ảnh

image.resize

Thay đổi kích thước hình ảnh theo kích thước chỉ định với các thuật toán khác nhau

Parameters:

NameTypeRequiredDefaultDescription
input_pathstringYes-Path to the input image file
output_pathstringNo-Path where the processed image will be saved
widthnumberNo-Target width in pixels
heightnumberNo-Target height in pixels
scalenumberNo-Scale factor (e.g., 0.5 for half, 2.0 for double)
algorithmselect (lanczos, bicubic, bilinear, nearest)NolanczosResampling algorithm for resize
maintain_aspectbooleanNoTrueMaintain original aspect ratio

Output:

FieldTypeDescription
output_pathstringĐường dẫn đến hình ảnh đã thay đổi kích thước
original_sizeobjectĐường dẫn đến hình ảnh đã thay đổi kích thước
new_sizeobjectĐường dẫn đến hình ảnh đã thay đổi kích thước

Example: Resize to specific dimensions

yaml
input_path: /path/to/image.png
width: 800
height: 600

Example: Scale by factor

yaml
input_path: /path/to/image.png
scale: 0.5

Xoay Ảnh

image.rotate

Xoay hình ảnh theo độ chỉ định

Parameters:

NameTypeRequiredDefaultDescription
input_pathstringYes-Đường dẫn đến ảnh đầu vào
output_pathstringYes-Đường dẫn cho ảnh đầu ra
anglenumberYes-Góc xoay tính bằng độ
expandbooleanNoTrueMở rộng đầu ra để chứa toàn bộ ảnh đã xoay
fill_colorstringNo#000000Màu để lấp đầy vùng trống sau khi xoay

Output:

FieldTypeDescription
output_pathstringĐường dẫn đến ảnh đã xoay
widthintegerChiều rộng của ảnh đã xoay
heightintegerChiều cao của ảnh đã xoay
anglenumberGóc xoay của ảnh

Example: Rotate 90 degrees

yaml
input_path: /path/to/image.png
output_path: /path/to/rotated.png
angle: 90

Thêm Watermark

image.watermark

Thêm watermark văn bản hoặc hình ảnh vào ảnh

Parameters:

NameTypeRequiredDefaultDescription
input_pathstringYes-Đường dẫn đến hình ảnh đầu vào
output_pathstringYes-Đường dẫn cho hình ảnh đầu ra
textstringNo-Văn bản dùng làm watermark
watermark_imagestringNo-Đường dẫn đến tệp hình ảnh dùng làm watermark
positionselect (center, top-left, top-right, bottom-left, bottom-right)Nobottom-rightVị trí của watermark trên hình ảnh
opacitynumberNo0.5Độ mờ của watermark (0.0 đến 1.0)
font_sizenumberNo36Kích thước chữ cho watermark văn bản

Output:

FieldTypeDescription
output_pathstringĐường dẫn đến hình ảnh đã thêm watermark
watermark_typestringLoại watermark áp dụng (chữ hoặc hình ảnh)

Example: Add text watermark

yaml
input_path: /path/to/image.png
output_path: /path/to/watermarked.png
text: © 2026 Company
position: bottom-right
opacity: 0.5

Released under the Apache 2.0 License.