Skip to content

conversiontools.imagemagick #

Imagemagick

example how to use

import freeflowuniverse.crystallib.conversiontools.imagemagick

imagemagick.downsize(
    path:'/tmp/mydir'
    backupdir:'/tmp/mybackup'
    redo:true //will re-process
    convertpng:true //will convert from png to jpeg
)!

imagemagick.downsize(
    path:'/tmp/mydir/myimage.png'
    backupdir:'/tmp/mybackup'
    redo:true //will re-process
    convertpng:false //will not convert to jpeg
)!

example output of image once identified

Image{
    path: path: /tmp/code/github/threefoldfoundation/www_examplesite/src/assets/images/sliders/availability.png
    size_x: 1448
    size_y: 573
    resolution_x: 28
    resolution_y: 28
    size_kbyte: 414
    transparent: true
}

fn downsize #

fn downsize(args DownsizeArgs) !

struct ScanArgs{ path string //where to start from backupdir string //if you want a backup dir } will return the paths of the images which were downsized

fn image_new #

fn image_new(mut path pathlib.Path) !Image

fn installed #

fn installed() bool

struct DownsizeArgs #

struct DownsizeArgs {
pub:
	path       string // can be single file or dir
	backupdir  string
	redo       bool // if you want to check the file again, even if processed
	convertpng bool // if yes will go from png to jpg
}

struct Image #

struct Image {
pub mut:
	path         pathlib.Path
	size_x       int
	size_y       int
	resolution_x int
	resolution_y int
	size_kbyte   int
	transparent  bool
}

fn (Image) downsize #

fn (mut image Image) downsize(args DownsizeArgsInternal) !

will downsize to reasonable size based on x

fn (Image) identify #

fn (mut image Image) identify() !

fn (Image) is_png #

fn (mut image Image) is_png() bool