pixelbin 1.0.7

SDKflutter
Platformandroidioswindowslinuxmacos

Real-time image transformations with automatic optimization, image URL and storage for efficient image organization

Pixelbin

Pixelbin Dart library helps you integrate Pixelbin with your Dart/Flutter Application.

Usage

Install using Pub Package Manager

Run this command:

  • With Dart:
     dart pub add pixelbin
  • With Flutter:
     flutter pub add pixelbin

OR

  • This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):
dependencies:
  pixelbin: ^latest_release_version

Creating Image from URL or Cloud details

import 'package:pixelbin/pixelbin_dart_sdk.dart';
final PixelBinImage? imageFromUrl = PixelBin.shared.imageFromUrl(
        "https://cdn.pixelbin.io/v2/dummy-cloudname/original/__playground/playground-default.jpeg");
debugPrint(imageFromUrl?.encoded);
// Create Image url from cloud, zone and other details
final PixelBinImage imageFromDetails = pixelBin.image(
          imagePath: imageFromUrl.imagePath, cloud: imageFromUrl.cloudName, transformations: imageFromUrl.transformations, version: imageFromUrl.version);
debugPrint(imageFromDetails.encoded);

Applying Transformations and Getting Transformations

import 'package:pixelbin/pixelbin_dart_sdk.dart';
// Create Image url from cloud, zone and imagePath on cloud (Not local path)
final image = PixelBin.shared.image(imagePath: "example/logo/apple.jpg", cloud: "apple_cloud", zone: "south_asia");
      debugPrint(imageFromDetails.encoded); // https://cdn.pixelbin.io/v2/apple_cloud/south_asia/original/example/logo/apple.jpg
final resizeTransformation = Transformation.tResize(height: 200, width: 200); // Creating Resize Transformation
image.addTransformations([eraseTransformation, resizeTransformation]); // Applying multiple transformations with list(keep passing all transformations in list)
// OR
image.addTransformation(resizeTransformation); // Applying transformations one by one
final outputUrl = image.encoded; // https://cdn.pixelbin.io/v2/apple_cloud/south_asia/erase.bg()~t.resize(h:100,w:100)/example/logo/apple.jpg
debugPrint(outputUrl);

Uploading Image and getting url object

// Signed Url and Field can be generated via using Backed SDK for pixelbin or API to generate signed url for upload
// Assume imagePath: "example/logo/apple.jpg", cloud: "apple_cloud", zone: "south_asia" & generate details
final signUrl = "SIGNED_URL";
final fields = {// Key: Value}; // META_DATA in value
final signedDetails = SignedDetails(url: signUrl, fields: fields)
// file is local picked file, other fields chunkSize: Int = 1024, concurrency: Int = 1
try {
     final signedDetails = SignedDetails(url: signUrl,fields:fields);
     final PixelBinImage? uploadResponse = await PixelBin.shared
          .upload(file: file, signedDetails: signedDetails);
     debugPrint("Response:=> ${uploadResponse?.encoded}");
    } catch (e) {
     debugPrint("Error:=> ${e.toString()}");
    }
ParameterTypeDescription
file (File)FileFile to upload to Pixelbin
signedDetails (SignedDetails)ObjectSigned details generated with the Pixelbin Backend SDK
chunkSize (Int)IntegerSize of chunks to be uploaded in KB (default value is 1024)
concurrency (Int)IntegerNumber of chunks to be uploaded in parallel API calls
  • Resolves with Image object on success.
  • Rejects with error on failure.

List of Supported Transformations

DetectBackgroundType

1. dbtDetect()

Classifies the background of a product as plain, clean or busy

final t = Transformation.dbtDetect(
        );

Basic

1. tResize(height, width, fit, background, position, algorithm, dpr)

Basic Transformations

ParameterTypeDefault
heightinteger0
widthinteger0
fitenumcover, contain, fill, inside, outsideTFit.cover
backgroundcolor"000000"
positionenumtop, bottom, left, right, right_top, right_bottom, left_top, left_bottom, centerTPosition.center
algorithmenumnearest, cubic, mitchell, lanczos2, lanczos3TAlgorithm.lanczos3
dprfloat1
final t = Transformation.tResize(
        height: 0,
        width: 0,
        fit: TFit.cover,
        background: "000000",
        position: TPosition.center,
        algorithm: TAlgorithm.lanczos3,
        dpr: 1
        );

2. tCompress(quality)

Basic Transformations

ParameterTypeDefault
qualityinteger80
final t = Transformation.tCompress(
        quality: 80
        );

3. tExtend(top, left, bottom, right, background, borderType, dpr)

Basic Transformations

ParameterTypeDefault
topinteger10
leftinteger10
bottominteger10
rightinteger10
backgroundcolor"000000"
borderTypeenumconstant, replicate, reflect, wrapTBorderType.constant
dprfloat1
final t = Transformation.tExtend(
        top: 10,
        left: 10,
        bottom: 10,
        right: 10,
        background: "000000",
        borderType: TBorderType.constant,
        dpr: 1
        );

4. tExtract(top, left, height, width, boundingBox)

Basic Transformations

ParameterTypeDefault
topinteger10
leftinteger10
heightinteger50
widthinteger20
boundingBoxbboxnull
final t = Transformation.tExtract(
        top: 10,
        left: 10,
        height: 50,
        width: 20,
        boundingBox: null
        );

5. tTrim(threshold)

Basic Transformations

ParameterTypeDefault
thresholdinteger10
final t = Transformation.tTrim(
        threshold: 10
        );

6. tRotate(angle, background)

Basic Transformations

ParameterTypeDefault
angleinteger0
backgroundcolor"000000"
final t = Transformation.tRotate(
        angle: 0,
        background: "000000"
        );

7. tFlip()

Basic Transformations

final t = Transformation.tFlip(
        );

8. tFlop()

Basic Transformations

final t = Transformation.tFlop(
        );

9. tSharpen(sigma)

Basic Transformations

ParameterTypeDefault
sigmafloat1.5
final t = Transformation.tSharpen(
        sigma: 1.5
        );

10. tMedian(size)

Basic Transformations

ParameterTypeDefault
sizeinteger3
final t = Transformation.tMedian(
        size: 3
        );

11. tBlur(sigma, dpr)

Basic Transformations

ParameterTypeDefault
sigmafloat0.3
dprfloat1
final t = Transformation.tBlur(
        sigma: 0.3,
        dpr: 1
        );

12. tFlatten(background)

Basic Transformations

ParameterTypeDefault
backgroundcolor"000000"
final t = Transformation.tFlatten(
        background: "000000"
        );

13. tNegate()

Basic Transformations

final t = Transformation.tNegate(
        );

14. tNormalise()

Basic Transformations

final t = Transformation.tNormalise(
        );

15. tLinear(a, b)

Basic Transformations

ParameterTypeDefault
ainteger1
binteger0
final t = Transformation.tLinear(
        a: 1,
        b: 0
        );

16. tModulate(brightness, saturation, hue)

Basic Transformations

ParameterTypeDefault
brightnessfloat1
saturationfloat1
hueinteger90
final t = Transformation.tModulate(
        brightness: 1,
        saturation: 1,
        hue: 90
        );

17. tGrey()

Basic Transformations

final t = Transformation.tGrey(
        );

18. tTint(color)

Basic Transformations

ParameterTypeDefault
colorcolor"000000"
final t = Transformation.tTint(
        color: "000000"
        );

19. tToformat(format, quality)

Basic Transformations

ParameterTypeDefault
formatenumjpeg, png, webp, tiff, avif, bmp, heifTFormat.jpeg
qualityenum100, 95, 90, 85, 80, 75, 70, 60, 50, 40, 30, 20, 10, best, good, eco, lowTQuality.p75
final t = Transformation.tToformat(
        format: TFormat.jpeg,
        quality: TQuality.p75
        );

20. tDensity(density)

Basic Transformations

ParameterTypeDefault
densityinteger300
final t = Transformation.tDensity(
        density: 300
        );

21. tMerge(mode, image, transformation, background, height, width, top, left, gravity, blend, tile, listOfBboxes, listOfPolygons)

Basic Transformations

ParameterTypeDefault
modeenumoverlay, underlay, wrapTMode.overlay
imagefile""
transformationcustom""
backgroundcolor"00000000"
heightinteger0
widthinteger0
topinteger0
leftinteger0
gravityenumnorthwest, north, northeast, east, center, west, southwest, south, southeast, customTGravity.center
blendenumover, in, out, atop, dest, dest-over, dest-in, dest-out, dest-atop, xor, add, saturate, multiply, screen, overlay, darken, lighten, colour-dodge, color-dodge, colour-burn, color-burn, hard-light, soft-light, difference, exclusionTBlend.over
tilebooleanfalse
listOfBboxesbboxListnull
listOfPolygonspolygonListnull
final t = Transformation.tMerge(
        mode: TMode.overlay,
        image: "",
        transformation: "",
        background: "00000000",
        height: 0,
        width: 0,
        top: 0,
        left: 0,
        gravity: TGravity.center,
        blend: TBlend.over,
        tile: false,
        listOfBboxes: null,
        listOfPolygons: null
        );

Artifact

1. afRemove()

Artifact Removal Plugin

final t = Transformation.afRemove(
        );

AWSRekognitionPlugin

1. awsrekDetectlabels(maximumLabels, minimumConfidence)

Detect objects and text in images

ParameterTypeDefault
maximumLabelsinteger5
minimumConfidenceinteger55
final t = Transformation.awsrekDetectlabels(
        maximumLabels: 5,
        minimumConfidence: 55
        );

2. awsrekModeration(minimumConfidence)

Detect objects and text in images

ParameterTypeDefault
minimumConfidenceinteger55
final t = Transformation.awsrekModeration(
        minimumConfidence: 55
        );

BackgroundGenerator

1. generateBg(backgroundPrompt, focus, negativePrompt, seed)

AI Background Generator

ParameterTypeDefault
backgroundPromptcustom"YSBmb3Jlc3QgZnVsbCBvZiBvYWsgdHJlZXMsd2l0aCBicmlnaHQgbGlnaHRzLCBzdW4gYW5kIGEgbG90IG9mIG1hZ2ljLCB1bHRyYSByZWFsaXN0aWMsIDhr"
focusenumProduct, BackgroundGenerateFocus.product
negativePromptcustom""
seedinteger123
final t = Transformation.generateBg(
        backgroundPrompt: "YSBmb3Jlc3QgZnVsbCBvZiBvYWsgdHJlZXMsd2l0aCBicmlnaHQgbGlnaHRzLCBzdW4gYW5kIGEgbG90IG9mIG1hZ2ljLCB1bHRyYSByZWFsaXN0aWMsIDhr",
        focus: GenerateFocus.product,
        negativePrompt: "",
        seed: 123
        );

ImageExtender

1. bgExtend(boundingBox, prompt, negativePrompt, strength, guidanceScale, numberOfInferenceSteps, colorAdjust, seed)

AI Image Extender

ParameterTypeDefault
boundingBoxbboxnull
promptcustom""
negativePromptcustom""
strengthfloat0.999
guidanceScaleinteger8
numberOfInferenceStepsinteger10
colorAdjustbooleanfalse
seedinteger123
final t = Transformation.bgExtend(
        boundingBox: null,
        prompt: "",
        negativePrompt: "",
        strength: 0.999,
        guidanceScale: 8,
        numberOfInferenceSteps: 10,
        colorAdjust: false,
        seed: 123
        );

VariationGenerator

1. vgGenerate(generateVariationPrompt, noOfVariations, seed, autoscale)

AI Variation Generator

ParameterTypeDefault
generateVariationPromptcustom""
noOfVariationsinteger1
seedinteger0
autoscalebooleantrue
final t = Transformation.vgGenerate(
        generateVariationPrompt: "",
        noOfVariations: 1,
        seed: 0,
        autoscale: true
        );

EraseBG

1. eraseBg(industryType, addShadow, refine)

EraseBG Background Removal Module

ParameterTypeDefault
industryTypeenumgeneral, ecommerce, car, human, objectEraseIndustryType.general
addShadowbooleanfalse
refinebooleantrue
final t = Transformation.eraseBg(
        industryType: EraseIndustryType.general,
        addShadow: false,
        refine: true
        );

GoogleVisionPlugin

1. googlevisDetectlabels(maximumLabels)

Detect content and text in images

ParameterTypeDefault
maximumLabelsinteger5
final t = Transformation.googlevisDetectlabels(
        maximumLabels: 5
        );

ImageCentering

1. imcDetect(distancePercentage)

Image Centering Module

ParameterTypeDefault
distancePercentageinteger10
final t = Transformation.imcDetect(
        distancePercentage: 10
        );

IntelligentCrop

1. icCrop(requiredWidth, requiredHeight, paddingPercentage, maintainOriginalAspect, aspectRatio, gravityTowards, preferredDirection, objectType)

Intelligent Crop Plugin

ParameterTypeDefault
requiredWidthinteger0
requiredHeightinteger0
paddingPercentageinteger0
maintainOriginalAspectbooleanfalse
aspectRatiostring""
gravityTowardsenumobject, foreground, face, noneIcGravitytowards.none
preferredDirectionenumnorth_west, north, north_east, west, center, east, south_west, south, south_eastIcPreferreddirection.center
objectTypeenumairplane, apple, backpack, banana, baseball_bat, baseball_glove, bear, bed, bench, bicycle, bird, boat, book, bottle, bowl, broccoli, bus, cake, car, carrot, cat, cell_phone, chair, clock, couch, cow, cup, dining_table, dog, donut, elephant, fire_hydrant, fork, frisbee, giraffe, hair_drier, handbag, horse, hot_dog, keyboard, kite, knife, laptop, microwave, motorcycle, mouse, orange, oven, parking_meter, person, pizza, potted_plant, refrigerator, remote, sandwich, scissors, sheep, sink, skateboard, skis, snowboard, spoon, sports_ball, stop_sign, suitcase, surfboard, teddy_bear, tennis_racket, tie, toaster, toilet, toothbrush, traffic_light, train, truck, tv, umbrella, vase, wine_glass, zebraIcObjectType.person
final t = Transformation.icCrop(
        requiredWidth: 0,
        requiredHeight: 0,
        paddingPercentage: 0,
        maintainOriginalAspect: false,
        aspectRatio: "",
        gravityTowards: IcGravitytowards.none,
        preferredDirection: IcPreferreddirection.center,
        objectType: IcObjectType.person
        );

IntelligentMasking

1. imMask(replacementImage, detector, maskType)

Intelligent Masking

ParameterTypeDefault
replacementImagefile""
detectorenumface, text, number_plateImDetector.numberPlate
maskTypeenumfill_black, pixelate, blurImMaskType.fillBlack
final t = Transformation.imMask(
        replacementImage: "",
        detector: ImDetector.numberPlate,
        maskType: ImMaskType.fillBlack
        );

ObjectCounter

1. ocDetect()

Classifies whether objects in the image are single or multiple

final t = Transformation.ocDetect(
        );

NSFWDetection

1. nsfwDetect(minimumConfidence)

Detect NSFW content in images

ParameterTypeDefault
minimumConfidencefloat0.5
final t = Transformation.nsfwDetect(
        minimumConfidence: 0.5
        );

NumberPlateDetection

1. numplateDetect()

Number Plate Detection Plugin

final t = Transformation.numplateDetect(
        );

ObjectDetection

1. odDetect()

Detect bounding boxes of objects in the image

final t = Transformation.odDetect(
        );

CheckObjectSize

1. cosDetect(objectThresholdPercent)

Calculates the percentage of the main object area relative to image dimensions.

ParameterTypeDefault
objectThresholdPercentinteger50
final t = Transformation.cosDetect(
        objectThresholdPercent: 50
        );

TextDetectionandRecognition

1. ocrExtract(detectOnly)

OCR Module

ParameterTypeDefault
detectOnlybooleanfalse
final t = Transformation.ocrExtract(
        detectOnly: false
        );

PdfWatermarkRemoval

1. pwrRemove()

PDF Watermark Removal Plugin

final t = Transformation.pwrRemove(
        );

ProductTagging

1. prTag()

AI Product Tagging

final t = Transformation.prTag(
        );

CheckProductVisibility

1. cpvDetect()

Classifies whether the product in the image is completely visible or not

final t = Transformation.cpvDetect(
        );

QRCode

1. qrGenerate(width, height, image, margin, qRTypeNumber, qrErrorCorrectionLevel, imageSize, imageMargin, dotsColor, dotsType, dotsBgColor, cornerSquareColor, cornerSquareType, cornerDotsColor, cornerDotsType)

QRCode Plugin

ParameterTypeDefault
widthinteger300
heightinteger300
imagecustom""
margininteger0
qRTypeNumberinteger0
qrErrorCorrectionLevelenumL, M, Q, HQrQrerrorcorrectionlevel.q
imageSizefloat0.4
imageMargininteger0
dotsColorcolor"000000"
dotsTypeenumrounded, dots, classy, classy-rounded, square, extra-roundedQrDotsType.square
dotsBgColorcolor"ffffff"
cornerSquareColorcolor"000000"
cornerSquareTypeenumdot, square, extra-roundedQrCornersquareType.square
cornerDotsColorcolor"000000"
cornerDotsTypeenumdot, squareQrCornerdotsType.dot
final t = Transformation.qrGenerate(
        width: 300,
        height: 300,
        image: "",
        margin: 0,
        qRTypeNumber: 0,
        qrErrorCorrectionLevel: QrQrerrorcorrectionlevel.q,
        imageSize: 0.4,
        imageMargin: 0,
        dotsColor: "000000",
        dotsType: QrDotsType.square,
        dotsBgColor: "ffffff",
        cornerSquareColor: "000000",
        cornerSquareType: QrCornersquareType.square,
        cornerDotsColor: "000000",
        cornerDotsType: QrCornerdotsType.dot
        );

2. qrScan()

QRCode Plugin

final t = Transformation.qrScan(
        );

RemoveBG

1. removeBg()

Remove background from any image

final t = Transformation.removeBg(
        );

SoftShadowGenerator

1. shadowGen(backgroundImage, backgroundColor, shadowAngle, shadowIntensity)

AI Soft Shadow Generator

ParameterTypeDefault
backgroundImagefilenull
backgroundColorcolor"ffffff"
shadowAnglefloat120
shadowIntensityfloat0.5
final t = Transformation.shadowGen(
        backgroundImage: null,
        backgroundColor: "ffffff",
        shadowAngle: 120,
        shadowIntensity: 0.5
        );

SuperResolution

1. srUpscale(type, enhanceFace, model, enhanceQuality)

Super Resolution Module

ParameterTypeDefault
typeenum2x, 4x, 8xSrType.p2x
enhanceFacebooleanfalse
modelenumPicasso, FlashSrModel.picasso
enhanceQualitybooleanfalse
final t = Transformation.srUpscale(
        type: SrType.p2x,
        enhanceFace: false,
        model: SrModel.picasso,
        enhanceQuality: false
        );

VertexAI

1. vertexaiGeneratebg(backgroundPrompt, negativePrompt, seed, guidanceScale)

Vertex AI based transformations

ParameterTypeDefault
backgroundPromptcustom"YSBmb3Jlc3QgZnVsbCBvZiBvYWsgdHJlZXMsd2l0aCBicmlnaHQgbGlnaHRzLCBzdW4gYW5kIGEgbG90IG9mIG1hZ2ljLCB1bHRyYSByZWFsaXN0aWMsIDhr"
negativePromptcustom""
seedinteger22
guidanceScaleinteger60
final t = Transformation.vertexaiGeneratebg(
        backgroundPrompt: "YSBmb3Jlc3QgZnVsbCBvZiBvYWsgdHJlZXMsd2l0aCBicmlnaHQgbGlnaHRzLCBzdW4gYW5kIGEgbG90IG9mIG1hZ2ljLCB1bHRyYSByZWFsaXN0aWMsIDhr",
        negativePrompt: "",
        seed: 22,
        guidanceScale: 60
        );

2. vertexaiRemovebg()

Vertex AI based transformations

final t = Transformation.vertexaiRemovebg(
        );

3. vertexaiUpscale(type)

Vertex AI based transformations

ParameterTypeDefault
typeenumx2, x4VertexaiType.x2
final t = Transformation.vertexaiUpscale(
        type: VertexaiType.x2
        );

VideoWatermarkRemoval

1. wmvRemove()

Video Watermark Removal Plugin

final t = Transformation.wmvRemove(
        );

VideoUpscalerPlugin

1. vsrUpscale()

Video Upscaler Plugin

final t = Transformation.vsrUpscale(
        );

ViewDetection

1. vdDetect()

Classifies wear type and view type of products in the image

final t = Transformation.vdDetect(
        );

WatermarkRemoval

1. wmRemove(removeText, removeLogo, box1, box2, box3, box4, box5)

Watermark Removal Plugin

ParameterTypeDefault
removeTextbooleanfalse
removeLogobooleanfalse
box1string"0_0_100_100"
box2string"0_0_0_0"
box3string"0_0_0_0"
box4string"0_0_0_0"
box5string"0_0_0_0"
final t = Transformation.wmRemove(
        removeText: false,
        removeLogo: false,
        box1: "0_0_100_100",
        box2: "0_0_0_0",
        box3: "0_0_0_0",
        box4: "0_0_0_0",
        box5: "0_0_0_0"
        );

WatermarkDetection

1. wmcDetect(detectText)

Watermark Detection Plugin

ParameterTypeDefault
detectTextbooleanfalse
final t = Transformation.wmcDetect(
        detectText: false
        );