Put all directories and images in database, use the info to associate an image to each artist
This commit is contained in:
@@ -25,6 +25,7 @@ if (${LMS_IMAGE_BACKEND} STREQUAL "stb")
|
||||
message(STATUS "Using stb (resize version ${STB_IMAGE_RESIZE_VERSION})")
|
||||
|
||||
target_sources(lmsimage PRIVATE
|
||||
impl/stb/Image.cpp
|
||||
impl/stb/JPEGImage.cpp
|
||||
impl/stb/RawImage.cpp
|
||||
)
|
||||
@@ -36,6 +37,7 @@ elseif (${LMS_IMAGE_BACKEND} STREQUAL "graphicsmagick")
|
||||
message(STATUS "Using graphicsmagick")
|
||||
|
||||
target_sources(lmsimage PRIVATE
|
||||
impl/graphicsmagick/Image.cpp
|
||||
impl/graphicsmagick/JPEGImage.cpp
|
||||
impl/graphicsmagick/RawImage.cpp
|
||||
)
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Emeric Poupon
|
||||
*
|
||||
* This file is part of LMS.
|
||||
*
|
||||
* LMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "image/Image.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "core/ILogger.hpp"
|
||||
#include "core/ITraceLogger.hpp"
|
||||
|
||||
namespace lms::image
|
||||
{
|
||||
std::unique_ptr<IRawImage> decodeImage(const std::byte* encodedData, std::size_t encodedDataSize)
|
||||
{
|
||||
return std::make_unique<GraphicsMagick::RawImage>(encodedData, encodedDataSize);
|
||||
}
|
||||
|
||||
std::unique_ptr<IRawImage> decodeImage(const std::filesystem::path& path)
|
||||
{
|
||||
return std::make_unique<GraphicsMagick::RawImage>(path);
|
||||
}
|
||||
|
||||
void init(const std::filesystem::path& path)
|
||||
{
|
||||
Magick::InitializeMagick(path.string().c_str());
|
||||
|
||||
if (auto nbThreads{ MagickLib::GetMagickResourceLimit(MagickLib::ThreadsResource) }; nbThreads != 1)
|
||||
LMS_LOG(COVER, WARNING, "Consider setting env var OMP_NUM_THREADS=1 to save resources");
|
||||
|
||||
if (!MagickLib::SetMagickResourceLimit(MagickLib::ThreadsResource, 1))
|
||||
LMS_LOG(COVER, ERROR, "Cannot set Magick thread resource limit to 1!");
|
||||
|
||||
if (!MagickLib::SetMagickResourceLimit(MagickLib::DiskResource, 0))
|
||||
LMS_LOG(COVER, ERROR, "Cannot set Magick disk resource limit to 0!");
|
||||
|
||||
LMS_LOG(COVER, INFO, "Magick threads resource limit = " << GetMagickResourceLimit(MagickLib::ThreadsResource));
|
||||
LMS_LOG(COVER, INFO, "Magick Disk resource limit = " << GetMagickResourceLimit(MagickLib::DiskResource));
|
||||
}
|
||||
|
||||
std::span<const std::filesystem::path> getSupportedFileExtensions()
|
||||
{
|
||||
static const std::array<std::filesystem::path, 4> fileExtensions{ ".jpg", ".jpeg", ".png", ".bmp" };
|
||||
return fileExtensions;
|
||||
}
|
||||
} // namespace lms::image
|
||||
@@ -19,6 +19,9 @@
|
||||
|
||||
#include "RawImage.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
#include <magick/resource.h>
|
||||
|
||||
#include "core/ILogger.hpp"
|
||||
@@ -26,39 +29,8 @@
|
||||
|
||||
#include "JPEGImage.hpp"
|
||||
|
||||
namespace lms::image
|
||||
{
|
||||
std::unique_ptr<IRawImage> decodeImage(const std::byte* encodedData, std::size_t encodedDataSize)
|
||||
{
|
||||
return std::make_unique<GraphicsMagick::RawImage>(encodedData, encodedDataSize);
|
||||
}
|
||||
|
||||
std::unique_ptr<IRawImage> decodeImage(const std::filesystem::path& path)
|
||||
{
|
||||
return std::make_unique<GraphicsMagick::RawImage>(path);
|
||||
}
|
||||
|
||||
void init(const std::filesystem::path& path)
|
||||
{
|
||||
Magick::InitializeMagick(path.string().c_str());
|
||||
|
||||
if (auto nbThreads{ MagickLib::GetMagickResourceLimit(MagickLib::ThreadsResource) }; nbThreads != 1)
|
||||
LMS_LOG(COVER, WARNING, "Consider setting env var OMP_NUM_THREADS=1 to save resources");
|
||||
|
||||
if (!MagickLib::SetMagickResourceLimit(MagickLib::ThreadsResource, 1))
|
||||
LMS_LOG(COVER, ERROR, "Cannot set Magick thread resource limit to 1!");
|
||||
|
||||
if (!MagickLib::SetMagickResourceLimit(MagickLib::DiskResource, 0))
|
||||
LMS_LOG(COVER, ERROR, "Cannot set Magick disk resource limit to 0!");
|
||||
|
||||
LMS_LOG(COVER, INFO, "Magick threads resource limit = " << GetMagickResourceLimit(MagickLib::ThreadsResource));
|
||||
LMS_LOG(COVER, INFO, "Magick Disk resource limit = " << GetMagickResourceLimit(MagickLib::DiskResource));
|
||||
}
|
||||
} // namespace lms::image
|
||||
|
||||
namespace lms::image::GraphicsMagick
|
||||
{
|
||||
|
||||
RawImage::RawImage(const std::byte* encodedData, std::size_t encodedDataSize)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Emeric Poupon
|
||||
*
|
||||
* This file is part of LMS.
|
||||
*
|
||||
* LMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "image/Image.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "RawImage.hpp"
|
||||
#include "core/ITraceLogger.hpp"
|
||||
|
||||
namespace lms::image
|
||||
{
|
||||
std::unique_ptr<IRawImage> decodeImage(const std::byte* encodedData, std::size_t encodedDataSize)
|
||||
{
|
||||
LMS_SCOPED_TRACE_DETAILED("Image", "DecodeBuffer");
|
||||
return std::make_unique<STB::RawImage>(encodedData, encodedDataSize);
|
||||
}
|
||||
|
||||
std::unique_ptr<IRawImage> decodeImage(const std::filesystem::path& path)
|
||||
{
|
||||
LMS_SCOPED_TRACE_DETAILED("Image", "DecodeFile");
|
||||
return std::make_unique<STB::RawImage>(path);
|
||||
}
|
||||
|
||||
void init(const std::filesystem::path&)
|
||||
{
|
||||
}
|
||||
|
||||
std::span<const std::filesystem::path> getSupportedFileExtensions()
|
||||
{
|
||||
static const std::array<std::filesystem::path, 4> fileExtensions{ ".jpg", ".jpeg", ".png", ".bmp" };
|
||||
return fileExtensions;
|
||||
}
|
||||
} // namespace lms::image
|
||||
@@ -41,25 +41,6 @@
|
||||
|
||||
#include "JPEGImage.hpp"
|
||||
|
||||
namespace lms::image
|
||||
{
|
||||
std::unique_ptr<IRawImage> decodeImage(const std::byte* encodedData, std::size_t encodedDataSize)
|
||||
{
|
||||
LMS_SCOPED_TRACE_DETAILED("Image", "DecodeBuffer");
|
||||
return std::make_unique<STB::RawImage>(encodedData, encodedDataSize);
|
||||
}
|
||||
|
||||
std::unique_ptr<IRawImage> decodeImage(const std::filesystem::path& path)
|
||||
{
|
||||
LMS_SCOPED_TRACE_DETAILED("Image", "DecodeFile");
|
||||
return std::make_unique<STB::RawImage>(path);
|
||||
}
|
||||
|
||||
void init(const std::filesystem::path&)
|
||||
{
|
||||
}
|
||||
} // namespace lms::image
|
||||
|
||||
namespace lms::image::STB
|
||||
{
|
||||
RawImage::RawImage(const std::byte* encodedData, std::size_t encodedDataSize)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
|
||||
#include "image/IEncodedImage.hpp"
|
||||
#include "image/IRawImage.hpp"
|
||||
@@ -28,6 +29,7 @@
|
||||
namespace lms::image
|
||||
{
|
||||
void init(const std::filesystem::path& path);
|
||||
std::span<const std::filesystem::path> getSupportedFileExtensions();
|
||||
std::unique_ptr<IRawImage> decodeImage(const std::byte* encodedData, std::size_t encodedDataSize);
|
||||
std::unique_ptr<IRawImage> decodeImage(const std::filesystem::path& path);
|
||||
std::unique_ptr<IEncodedImage> readSvgFile(const std::filesystem::path& path);
|
||||
|
||||
Reference in New Issue
Block a user