You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-06 23:56:13 +02:00
Desktop: Added more methods to the imaging plugin API
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { Rectangle } from "./types";
|
||||
export interface Implementation {
|
||||
nativeImage: any;
|
||||
}
|
||||
@ -31,10 +32,47 @@ export default class JoplinImaging {
|
||||
private createImageHandle;
|
||||
private imageByHandle;
|
||||
private cacheImage;
|
||||
/**
|
||||
* Create an image from a buffer - however only use this for very small
|
||||
* images. It requires transferring the full image data from the plugin to
|
||||
* the app, which is extremely slow and will freeze the app. Instead, use
|
||||
* `createFromPath` or `createFromResource`, which will manipulate the image
|
||||
* data directly from the main process.
|
||||
*/
|
||||
createFromBuffer(buffer: any, options?: CreateFromBufferOptions): Promise<Handle>;
|
||||
createFromPath(filePath: string): Promise<Handle>;
|
||||
createFromResource(resourceId: string): Promise<Handle>;
|
||||
getSize(handle: Handle): Promise<any>;
|
||||
resize(handle: Handle, options?: ResizeOptions): Promise<string>;
|
||||
crop(handle: Handle, rectange: Rectangle): Promise<string>;
|
||||
/**
|
||||
* Warnings: requires transferring the complete image from the app to the
|
||||
* plugin which may freeze the app. Consider using one of the `toXxxFile()`
|
||||
* or `toXxxResource()` methods instead.
|
||||
*/
|
||||
toDataUrl(handle: Handle): Promise<string>;
|
||||
/**
|
||||
* Warnings: requires transferring the complete image from the app to the
|
||||
* plugin which may freeze the app. Consider using one of the `toXxxFile()`
|
||||
* or `toXxxResource()` methods instead.
|
||||
*/
|
||||
toBase64(handle: Handle): Promise<string>;
|
||||
toPngFile(handle: Handle, filePath: string): Promise<void>;
|
||||
/**
|
||||
* Quality is between 0 and 100
|
||||
*/
|
||||
toJpgFile(handle: Handle, filePath: string, quality?: number): Promise<void>;
|
||||
private tempFilePath;
|
||||
/**
|
||||
* Creates a new Joplin resource from the image data. The image will be
|
||||
* first converted to a JPEG.
|
||||
*/
|
||||
toJpgResource(handle: Handle, resourceProps: any, quality?: number): Promise<import("../../database/types").ResourceEntity>;
|
||||
/**
|
||||
* Creates a new Joplin resource from the image data. The image will be
|
||||
* first converted to a PNG.
|
||||
*/
|
||||
toPngResource(handle: Handle, resourceProps: any): Promise<import("../../database/types").ResourceEntity>;
|
||||
/**
|
||||
* Image data is not automatically deleted by Joplin so make sure you call
|
||||
* this method on the handle once you are done.
|
||||
|
@ -359,6 +359,13 @@ export interface DialogResult {
|
||||
formData?: any;
|
||||
}
|
||||
|
||||
export interface Rectangle {
|
||||
x?: number;
|
||||
y?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Settings types
|
||||
// =================================================================
|
||||
|
Reference in New Issue
Block a user