mirror of
https://github.com/viliusle/miniPaint.git
synced 2026-02-06 13:36:45 +00:00
resize with aspect ratio
This commit is contained in:
parent
f736445b3a
commit
6b7d1002d0
2
package-lock.json
generated
2
package-lock.json
generated
@ -4428,7 +4428,7 @@
|
||||
}
|
||||
},
|
||||
"hermite-resize": {
|
||||
"version": "git+https://github.com/viliusle/Hermite-resize.git#75fd0e77179ae0b5296488722eb114d18becca5f"
|
||||
"version": "git+https://github.com/viliusle/Hermite-resize.git#d88a9ee6df9555a4a9a5892ae570548a8384237f"
|
||||
},
|
||||
"hmac-drbg": {
|
||||
"version": "1.0.1",
|
||||
|
||||
@ -3,7 +3,7 @@ import Base_layers_class from './../../core/base-layers.js';
|
||||
import Base_gui_class from './../../core/base-gui.js';
|
||||
import Dialog_class from './../../libs/popup.js';
|
||||
import ImageFilters_class from './../../libs/imagefilters.js';
|
||||
import Hermite_class from './../../../../node_modules/hermite-resize/dist/hermite.npm.js';
|
||||
import Hermite_class from 'hermite-resize';
|
||||
import alertify from './../../../../node_modules/alertifyjs/build/alertify.min.js';
|
||||
|
||||
var instance = null;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import config from './../../config.js';
|
||||
import Base_gui_class from './../../core/base-gui.js';
|
||||
import Dialog_class from './../../libs/popup.js';
|
||||
import alertify from './../../../../node_modules/alertifyjs/build/alertify.min.js';
|
||||
|
||||
class Image_size_class {
|
||||
|
||||
@ -22,8 +23,8 @@ class Image_size_class {
|
||||
var settings = {
|
||||
title: 'Size',
|
||||
params: [
|
||||
{name: "w", title: "Width:", value: config.WIDTH},
|
||||
{name: "h", title: "Height:", value: config.HEIGHT},
|
||||
{name: "w", title: "Width:", value: config.WIDTH, placeholder: config.WIDTH},
|
||||
{name: "h", title: "Height:", value: config.HEIGHT, placeholder: config.HEIGHT},
|
||||
{name: "resolution", title: "Resolution:", values: resolutions},
|
||||
],
|
||||
on_finish: function (params) {
|
||||
@ -37,12 +38,27 @@ class Image_size_class {
|
||||
size_handler(data) {
|
||||
var width = parseInt(data.w);
|
||||
var height = parseInt(data.h);
|
||||
var ratio = config.WIDTH / config.HEIGHT;
|
||||
|
||||
if (width < 1)
|
||||
if (width < 1){
|
||||
width = 1;
|
||||
if (height < 1)
|
||||
}
|
||||
if (height < 1){
|
||||
height = 1;
|
||||
|
||||
}
|
||||
|
||||
//aspect ratio
|
||||
if (isNaN(width) && isNaN(height)){
|
||||
alertify.error('Wrong dimensions');
|
||||
return;
|
||||
}
|
||||
if (isNaN(width)){
|
||||
width = height * ratio;
|
||||
}
|
||||
if (isNaN(height)){
|
||||
height = width / ratio;
|
||||
}
|
||||
|
||||
if (data.resolution != 'Custom') {
|
||||
var dim = data.resolution.split(" ");
|
||||
dim = dim[0].split("x");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user