| 660 | } |
| 661 | |
| 662 | void MainWindowImpl::convert() |
| 663 | { |
| 664 | if ((treeWidget->topLevelItem(curr_index))->checkState(0)) { |
| 665 | IniSettings::setLatestWrittenFormatIndex(comboWFormats->currentIndex()); |
| 666 | statusBar()->showMessage(iAList->at(curr_index).fileName, 5000); |
| 667 | |
| 668 | QString out_format; |
| 669 | |
| 670 | QString inputFilename = iAList->at(curr_index).completeFileName; |
| 671 | |
| 672 | QFileInfo fi(inputFilename); |
| 673 | |
| 674 | QList<MagickDefine> magickDefines; |
| 675 | |
| 676 | if (comboWFormats->currentIndex() != 0) { |
| 677 | out_format = comboWFormats->currentText().split(" - ").at(0); |
| 678 | } |
| 679 | else { |
| 680 | QString suffix = fi.suffix(); |
| 681 | |
| 682 | out_format = suffix; |
| 683 | } |
| 684 | |
| 685 | out_format = out_format.toLower(); |
| 686 | |
| 687 | QString outFileName = QString("%1/%2.%3").arg(destinationPath()).arg(fi.completeBaseName()).arg(out_format); |
| 688 | |
| 689 | int quality = -1; |
| 690 | |
| 691 | /* |
| 692 | For further details: |
| 693 | http://www.imagemagick.org/script/command-line-options.php#quality |
| 694 | */ |
| 695 | |
| 696 | // Compression level 1-100 |
| 697 | if ((out_format == "jpg") || (out_format == "jpeg") || (out_format == "mpeg") || (out_format == "mpg")) { |
| 698 | quality = m_jpgQuality; |
| 699 | } |
| 700 | |
| 701 | // Compression level 0-9. For compression level 0 (quality value less than 10), the Huffman-only strategy is used |
| 702 | if ((out_format == "png") || (out_format == "mng")) { |
| 703 | quality = m_pngQuality * 10; |
| 704 | } |
| 705 | |
| 706 | if (out_format == "webp") { |
| 707 | quality = m_webPQuality; |
| 708 | |
| 709 | // magick, key, value |
| 710 | magickDefines << MagickDefine("webp", "lossless", (m_isWebPLosslessCompression) ? "true" : "false"); |
| 711 | magickDefines << MagickDefine("webp", "method", QString::number(m_webPCompression)); |
| 712 | magickDefines << MagickDefine("webp", "preprocessing", (m_iskWebPDithering) ? "1" : "0"); |
| 713 | } |
| 714 | |
| 715 | if (out_format == "avif") { |
| 716 | quality = 100; |
| 717 | magickDefines << MagickDefine("avif", "speed", "0"); |
| 718 | magickDefines << MagickDefine("heic", "chroma", "444"); |
| 719 | } |
nothing calls this directly
no test coverage detected