Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null image input & output #1776

Merged
merged 3 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ oiio_add_tests (
dither dup-channels
dpx ico iff
jpeg-corrupt-exif
png
null png
psd psd-colormodes
rla sgi
rational
Expand Down
21 changes: 18 additions & 3 deletions src/libOpenImageIO/imageioplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ catalog_plugin (const std::string &format_name,
PLUGENTRY (iff);
PLUGENTRY (jpeg);
PLUGENTRY (jpeg2000);
PLUGENTRY (null);
PLUGENTRY (openexr);
PLUGENTRY (png);
PLUGENTRY (pnm);
Expand Down Expand Up @@ -311,6 +312,7 @@ catalog_builtin_plugins ()
#ifdef USE_OPENJPEG
DECLAREPLUG (jpeg2000);
#endif
DECLAREPLUG (null);
DECLAREPLUG (openexr);
DECLAREPLUG (png);
DECLAREPLUG (pnm);
Expand Down Expand Up @@ -472,17 +474,30 @@ ImageInput::create (const std::string &filename,


ImageInput *
ImageInput::create (const std::string &filename,
ImageInput::create (const std::string &filename,
bool do_open,
const std::string &plugin_searchpath)
{
if (filename.empty()) { // Can't even guess if no filename given
// In case the 'filename' was really a REST-ful URI with query/config
// details tacked on to the end, strip them off so we can correctly
// extract the file extension.
std::map<std::string,std::string> args;
std::string filename_stripped;
if (! Strutil::get_rest_arguments (filename, filename_stripped, args)) {
pvt::error ("ImageInput::create() called with malformed filename");
return nullptr;
}

if (filename_stripped.empty())
filename_stripped = filename;

if (filename_stripped.empty()) { // Can't even guess if no filename given
pvt::error ("ImageInput::create() called with no filename");
return NULL;
}

// Extract the file extension from the filename (without the leading dot)
std::string format = Filesystem::extension (filename, false);
std::string format = Filesystem::extension (filename_stripped, false);
if (format.empty()) {
// If the file had no extension, maybe it was itself the format name
format = filename;
Expand Down
6 changes: 6 additions & 0 deletions src/libutil/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ Filesystem::read_bytes (string_view path, void *buffer, size_t n, size_t pos)
std::time_t
Filesystem::last_write_time (const std::string& path)
{
if (! exists(path))
return 0;
try {
#ifdef _WIN32
std::wstring wpath = Strutil::utf8_to_utf16 (path);
Expand All @@ -645,6 +647,8 @@ Filesystem::last_write_time (const std::string& path)
void
Filesystem::last_write_time (const std::string& path, std::time_t time)
{
if (! exists(path))
return;
try {
#ifdef _WIN32
std::wstring wpath = Strutil::utf8_to_utf16 (path);
Expand All @@ -662,6 +666,8 @@ Filesystem::last_write_time (const std::string& path, std::time_t time)
uint64_t
Filesystem::file_size (string_view path)
{
if (! exists(path))
return 0;
try {
#ifdef _WIN32
std::wstring wpath = Strutil::utf8_to_utf16 (path);
Expand Down
1 change: 1 addition & 0 deletions src/null.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_oiio_plugin (nullimageio.cpp)
Loading