images

package module
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2023 License: MIT Imports: 17 Imported by: 1

README

images

Description

图片处理库

Installation
go get gitee.com/eshax/images
Usage
  • go.mod
module image.test

go 1.17

require gitee.com/eshax/images v0.5.0
  • main.go
package main

import (
    "os"
    "gitee.com/eshax/images"
)

func main() {

    // 单图瓦片
    images.Single("dist/100x/0.jpg", "dist/100x/0/dzi", 256)

    // 连续视野瓦片
    images.Matrix("dist/lower", "dist/lower/dzi", 16384, 256)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ThreadPool = 100

Functions

func Buffer added in v0.3.0

func Buffer(source_path, extension string, bufSize, logicWidth, logicHeight, blockWidth, blockHeight, left, top int) (buffer image.Image, err error)

在逻辑大图中抠一个虚拟区域

在瓦片化的多个图像文件形成的逻辑大图中, 锁定一个固定大小的虚拟区域, 进行图像提取, 提取到内存中

source_folder_path: 原图像文件夹地址
	extension: 源文件的扩展名
		bufSize: 虚拟区域的固定大小

blockWidth & blockHeight: 原瓦片文件的宽度与高度

startX & startY: 虚拟区域位于逻辑大图的左上角

func BufferSize added in v0.3.0

func BufferSize(bufSize, tileSize int) int

func GetLevelSize added in v0.3.0

func GetLevelSize(logicWidth, logicHeight, level int) (int, int)

func GetMatrixInfo added in v0.3.0

func GetMatrixInfo(sourcePath string) (cols, rows, blockWidth, blockHeight, logicWidth, logicHeight int, extension string, err error)

获取矩阵信息

params:
	sourcePath: 源文件路径
returns:
	cols: 列
	rows: 行

func GetMaxLevel added in v0.3.0

func GetMaxLevel(width, height int) (max_level int)

func GetTileRect added in v0.3.0

func GetTileRect(width, height, col, row, tileSize int) (left, top, right, bottom int)

计算瓦片在原始逻辑图像中的坐标 params:

	 width: 逻辑图宽度
	height: 逻辑图高度
	   col: 列 (瓦片)
	   row: 行 (瓦片)
  tileSize: 瓦片尺寸 (正方形)

func Info

func Info(path string) (width, height int, err error)

func Load

func Load(img_path string) (img image.Image, err error)

图像加载

  1. 图片加载 params: img_path: 图片文件路径 returns: img: 图片对象 err: error

func Matrix added in v0.3.0

func Matrix(sourcePath, targetPath string, bufSize, tileSize, threadPool int)

Params:

sourcePath: 源文件路径
targetPath: 目标文件路径
bufSize: 缓冲区大小(2的n次方)(小于4096时默认使用4096)
tileSize: 瓦片大小(正方形图片边长)(默认256)

func Max added in v0.3.0

func Max(a, b int) int

func MergeFiles added in v0.5.0

func MergeFiles(source_path string) image.Image

将瓦片文件合并成一张大图

func Min added in v0.3.0

func Min(a, b int) int

func Resize

func Resize(source_path, target_path string, scale float64) error

等比例调整图片大小, 原路径替换文件

in:
	source_path: 源文件路径
	target_path: 目标文件路径
	scale: 缩放比例 (正数放大, 负数缩小)
out:
	err
example:
	images.Resize("image/0/a.jpg", "image/1/b.jpg",   2) // 放大一倍
	images.Resize("image/0/a.jpg", "image/1/b.jpg", 0.5) // 缩小一倍

func ResizeImage added in v0.2.0

func ResizeImage(source image.Image, scale float64) (target image.Image)

重置图像大小

params:
	source: image.Image (输入图像)
	scale:  缩放比例 (>1 放大) (<1 缩小)
returns:
	target: image.Image (输出图像)

func Save

func Save(img_path string, img image.Image) (err error)

func SaveTiles added in v0.3.0

func SaveTiles(targetPath string, tiles [][]image.Image, tileSize, x, y int) (err error)

保存瓦片到文件

input:

targetPath: 目标路径
	tiles: 瓦片数组
	tileSize: 瓦片尺寸
		x: 位于目标逻辑大图上的横向坐标
		y: 位于目标逻辑大图上的纵向坐标

func Single added in v0.5.1

func Single(sourceFilePath, targetPath string, tileSize int) (err error)

func Tile added in v0.3.0

func Tile(src image.Image, tileSize int) (dst [][]image.Image)

从原始逻辑图像中提取瓦片数据

input:

     src: 原始图像
tileSize: 瓦片尺寸

output:

dst: 瓦片数组

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL