2
* \file ResizeAlbumArt.qml
3
* Resize embedded cover art images which are larger than 500x500 pixels.
4
* The maximum size can be adapted by changing the maxPixels variable.
10
* Copyright (C) 2015 Urs Fleisch
12
* This program is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU Lesser General Public License as published by
14
* the Free Software Foundation; version 3.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public License
22
* along with this program. If not, see <http://www.gnu.org/licenses/>.
32
if (app.selectionInfo.tagFormatV2) {
33
var data = app.getPictureData()
34
if (script.getDataSize(data) !== 0) {
36
var img = script.dataToImage(data, format)
37
var imgProps = script.imageProperties(img)
38
if (typeof imgProps.width === "undefined") {
40
img = script.dataToImage(data, format)
41
imgProps = script.imageProperties(img)
43
var width = imgProps.width, height = imgProps.height
44
if (width > maxPixels || height > maxPixels) {
45
if (width >= height) {
46
width = maxPixels; height = -1
48
width = -1; height = maxPixels
50
img = script.scaleImage(img, width, height)
51
imgProps = script.imageProperties(img)
52
data = script.dataFromImage(img, format)
53
if (script.getDataSize(data) !== 0) {
54
app.setPictureData(data)
55
console.log("Resized image to %1x%2 in %3".
56
arg(imgProps.width).arg(imgProps.height).
57
arg(app.selectionInfo.fileName))
62
if (!app.nextFile()) {
64
// Save the changes if the script is started stand-alone, not from Kid3.