mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
notes and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
e4ad465eb0
commit
5406c071a9
@ -2751,6 +2751,8 @@ function(title, func){
|
|||||||
|
|
||||||
// XXX revise logging and logger passing...
|
// XXX revise logging and logger passing...
|
||||||
// XXX add a task manager UI...
|
// XXX add a task manager UI...
|
||||||
|
// XXX might be a good idea to confirm session task stops when loading a
|
||||||
|
// new index...
|
||||||
// XXX do we need to cache the lister props???
|
// XXX do we need to cache the lister props???
|
||||||
var TaskActions = actions.Actions({
|
var TaskActions = actions.Actions({
|
||||||
|
|
||||||
|
|||||||
@ -245,8 +245,11 @@ var SharpActions = actions.Actions({
|
|||||||
NOTE: all options are optional.
|
NOTE: all options are optional.
|
||||||
NOTE: this will not overwrite existing images.
|
NOTE: this will not overwrite existing images.
|
||||||
`,
|
`,
|
||||||
core.queueHandler('Make resized image',
|
core.sessionQueueHandler('Make resized image',
|
||||||
// get/normalize images...
|
// get/normalize images...
|
||||||
|
// XXX if this is to be a global task (i.e. .queueHandler(..)) we'll
|
||||||
|
// need to get all the image data here...
|
||||||
|
// ...paths and orientation data...
|
||||||
function(queue, images, size, path, options){
|
function(queue, images, size, path, options){
|
||||||
// sanity check...
|
// sanity check...
|
||||||
if(arguments.length < 4){
|
if(arguments.length < 4){
|
||||||
@ -262,7 +265,7 @@ var SharpActions = actions.Actions({
|
|||||||
: [images],
|
: [images],
|
||||||
...[...arguments].slice(2),
|
...[...arguments].slice(2),
|
||||||
]},
|
]},
|
||||||
function(image, size, path, options={}){
|
function(gid, size, path, options={}){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
// sizing...
|
// sizing...
|
||||||
@ -311,19 +314,19 @@ var SharpActions = actions.Actions({
|
|||||||
|
|
||||||
// skip non-images...
|
// skip non-images...
|
||||||
if(!['image', null, undefined]
|
if(!['image', null, undefined]
|
||||||
.includes(this.images[image].type)){
|
.includes(this.images[gid].type)){
|
||||||
// XXX what should we return???
|
// XXX what should we return???
|
||||||
return Promise.resolve() }
|
return Promise.resolve() }
|
||||||
|
|
||||||
// paths...
|
// paths...
|
||||||
var source = this.getImagePath(image)
|
var source = this.getImagePath(gid)
|
||||||
var to = pathlib.resolve(
|
var to = pathlib.resolve(
|
||||||
this.location.path,
|
this.location.path,
|
||||||
pathlib.join(
|
pathlib.join(
|
||||||
path,
|
path,
|
||||||
// if name is not a pattern do not re-format it...
|
// if name is not a pattern do not re-format it...
|
||||||
name.includes('%') ?
|
name.includes('%') ?
|
||||||
this.formatImageName(name, image, data || {})
|
this.formatImageName(name, gid, data || {})
|
||||||
: name))
|
: name))
|
||||||
|
|
||||||
var img = sharp(source)
|
var img = sharp(source)
|
||||||
@ -363,15 +366,15 @@ var SharpActions = actions.Actions({
|
|||||||
.clone()
|
.clone()
|
||||||
// handle transform (.orientation / .flip) and .crop...
|
// handle transform (.orientation / .flip) and .crop...
|
||||||
.run(function(){
|
.run(function(){
|
||||||
var img_data = that.images[image]
|
var img = that.images[gid]
|
||||||
if(transform && (img_data.orientation || img_data.flipped)){
|
if(transform && (img.orientation || img.flipped)){
|
||||||
img_data.orientation
|
img.orientation
|
||||||
&& this.rotate(img_data.orientation)
|
&& this.rotate(img.orientation)
|
||||||
img_data.flipped
|
img.flipped
|
||||||
&& img_data.flipped.includes('horizontal')
|
&& img.flipped.includes('horizontal')
|
||||||
&& this.flip() }
|
&& this.flip() }
|
||||||
img_data.flipped
|
img.flipped
|
||||||
&& img_data.flipped.includes('vertical')
|
&& img.flipped.includes('vertical')
|
||||||
&& this.flop()
|
&& this.flop()
|
||||||
// XXX CROP
|
// XXX CROP
|
||||||
//if(crop){
|
//if(crop){
|
||||||
@ -390,10 +393,6 @@ var SharpActions = actions.Actions({
|
|||||||
// XXX what should we return???
|
// XXX what should we return???
|
||||||
return to }) }) }) })],
|
return to }) }) }) })],
|
||||||
|
|
||||||
// XXX either make this a session task or make this survive loading
|
|
||||||
// a new index...
|
|
||||||
// XXX should this use .makeResizedImage(..) in sync mode???
|
|
||||||
// ...would be interesting to try a nested queue...
|
|
||||||
// XXX this does not update image.base_path -- is this correct???
|
// XXX this does not update image.base_path -- is this correct???
|
||||||
// XXX add support for offloading the processing to a thread/worker...
|
// XXX add support for offloading the processing to a thread/worker...
|
||||||
makePreviews: ['Sharp|File/Make image $previews',
|
makePreviews: ['Sharp|File/Make image $previews',
|
||||||
@ -422,8 +421,12 @@ var SharpActions = actions.Actions({
|
|||||||
|
|
||||||
NOTE: if base_path is given .images will not be updated with new
|
NOTE: if base_path is given .images will not be updated with new
|
||||||
preview paths...
|
preview paths...
|
||||||
|
NOTE: currently this is a core.sessionQueueHandler(..) and not a .queueHandler(..)
|
||||||
|
mainly because we need to add the preview refs back to the index and this
|
||||||
|
would need keeping the index in memory even if we loaded a different index,
|
||||||
|
this is possible but needs more thought.
|
||||||
`,
|
`,
|
||||||
core.queueHandler('Make image previews',
|
core.sessionQueueHandler('Make image previews',
|
||||||
function(queue, images, ...args){
|
function(queue, images, ...args){
|
||||||
// get/normalize images...
|
// get/normalize images...
|
||||||
return [
|
return [
|
||||||
@ -473,7 +476,10 @@ var SharpActions = actions.Actions({
|
|||||||
.replace(/\$RESOLUTION|\$\{RESOLUTION\}/g, parseInt(size))
|
.replace(/\$RESOLUTION|\$\{RESOLUTION\}/g, parseInt(size))
|
||||||
.replace(/\$GID|\$\{GID\}/g, gid)
|
.replace(/\$GID|\$\{GID\}/g, gid)
|
||||||
.replace(/\$NAME|\$\{NAME\}/g, img.name)
|
.replace(/\$NAME|\$\{NAME\}/g, img.name)
|
||||||
// XXX do we need this to be sync???
|
// NOTE: we are 'sync' here for several reasons, mainly because
|
||||||
|
// this is a small list and in this way we can take
|
||||||
|
// advantage of OS file caching, and removing the queue
|
||||||
|
// overhead, though small makes this noticeably faster...
|
||||||
return that.makeResizedImage('sync', gid, size, base, {
|
return that.makeResizedImage('sync', gid, size, base, {
|
||||||
name,
|
name,
|
||||||
skipSmaller: true,
|
skipSmaller: true,
|
||||||
@ -655,14 +661,17 @@ var SharpActions = actions.Actions({
|
|||||||
'cacheMetadata: "all" ...'],
|
'cacheMetadata: "all" ...'],
|
||||||
|
|
||||||
// shorthands...
|
// shorthands...
|
||||||
// XXX do we need these???
|
/*/ XXX do we need these???
|
||||||
// ...better have a task manager UI...
|
// ...better have a task manager UI...
|
||||||
|
// XXX if these are kept, would be fun to show them only if the respective
|
||||||
|
// tasks are running...
|
||||||
abortMakeResizedImage: ['- Sharp/',
|
abortMakeResizedImage: ['- Sharp/',
|
||||||
'tasks.stop: "makeResizedImage"'],
|
'tasks.stop: "makeResizedImage"'],
|
||||||
abortMakePreviews: ['- Sharp/',
|
abortMakePreviews: ['- Sharp/',
|
||||||
'tasks.stop: "makePreviews"'],
|
'tasks.stop: "makePreviews"'],
|
||||||
abortCacheMetadata: ['- Sharp/',
|
abortCacheMetadata: ['- Sharp/',
|
||||||
'tasks.stop: "cacheMetadata"'],
|
'tasks.stop: "cacheMetadata"'],
|
||||||
|
//*/
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user