Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
f1dc26d7
Commit
f1dc26d7
authored
Dec 09, 2018
by
LaurentBerger
Committed by
Alexander Alekhin
Dec 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge pull request #13382 from LaurentBerger:imreadsize
* try to solve #13381 * Add note
parent
40a53e3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
imgcodecs.hpp
modules/imgcodecs/include/opencv2/imgcodecs.hpp
+2
-0
loadsave.cpp
modules/imgcodecs/src/loadsave.cpp
+10
-9
No files found.
modules/imgcodecs/include/opencv2/imgcodecs.hpp
View file @
f1dc26d7
...
@@ -171,6 +171,8 @@ Currently, the following file formats are supported:
...
@@ -171,6 +171,8 @@ Currently, the following file formats are supported:
[Vector](http://www.gdal.org/ogr_formats.html).
[Vector](http://www.gdal.org/ogr_formats.html).
- If EXIF information are embedded in the image file, the EXIF orientation will be taken into account
- If EXIF information are embedded in the image file, the EXIF orientation will be taken into account
and thus the image will be rotated accordingly except if the flag @ref IMREAD_IGNORE_ORIENTATION is passed.
and thus the image will be rotated accordingly except if the flag @ref IMREAD_IGNORE_ORIENTATION is passed.
- By default number of pixels must be less than 2^30. Limit can be set using system
variable OPENCV_IO_MAX_IMAGE_PIXELS
@param filename Name of file to be loaded.
@param filename Name of file to be loaded.
@param flags Flag that can take values of cv::ImreadModes
@param flags Flag that can take values of cv::ImreadModes
...
...
modules/imgcodecs/src/loadsave.cpp
View file @
f1dc26d7
...
@@ -51,6 +51,8 @@
...
@@ -51,6 +51,8 @@
#undef max
#undef max
#include <iostream>
#include <iostream>
#include <fstream>
#include <fstream>
#include <opencv2/core/utils/configuration.private.hpp>
/****************************************************************************************\
/****************************************************************************************\
* Image Codecs *
* Image Codecs *
...
@@ -58,18 +60,17 @@
...
@@ -58,18 +60,17 @@
namespace
cv
{
namespace
cv
{
// TODO Add runtime configuration
static
const
size_t
CV_IO_MAX_IMAGE_PARAMS
=
cv
::
utils
::
getConfigurationParameterSizeT
(
"OPENCV_IO_MAX_IMAGE_PARAMS"
,
50
);
#define CV_IO_MAX_IMAGE_PARAMS (50)
static
const
size_t
CV_IO_MAX_IMAGE_WIDTH
=
utils
::
getConfigurationParameterSizeT
(
"OPENCV_IO_MAX_IMAGE_WIDTH"
,
1
<<
20
);
#define CV_IO_MAX_IMAGE_WIDTH (1<<20)
static
const
size_t
CV_IO_MAX_IMAGE_HEIGHT
=
utils
::
getConfigurationParameterSizeT
(
"OPENCV_IO_MAX_IMAGE_HEIGHT"
,
1
<<
20
);
#define CV_IO_MAX_IMAGE_HEIGHT (1<<20)
static
const
size_t
CV_IO_MAX_IMAGE_PIXELS
=
utils
::
getConfigurationParameterSizeT
(
"OPENCV_IO_MAX_IMAGE_PIXELS"
,
1
<<
30
);
#define CV_IO_MAX_IMAGE_PIXELS (1<<30) // 1 Gigapixel
static
Size
validateInputImageSize
(
const
Size
&
size
)
static
Size
validateInputImageSize
(
const
Size
&
size
)
{
{
CV_Assert
(
size
.
width
>
0
);
CV_Assert
(
size
.
width
>
0
);
CV_Assert
(
s
ize
.
width
<=
CV_IO_MAX_IMAGE_WIDTH
);
CV_Assert
(
s
tatic_cast
<
size_t
>
(
size
.
width
)
<=
CV_IO_MAX_IMAGE_WIDTH
);
CV_Assert
(
size
.
height
>
0
);
CV_Assert
(
size
.
height
>
0
);
CV_Assert
(
s
ize
.
height
<=
CV_IO_MAX_IMAGE_HEIGHT
);
CV_Assert
(
s
tatic_cast
<
size_t
>
(
size
.
height
)
<=
CV_IO_MAX_IMAGE_HEIGHT
);
uint64
pixels
=
(
uint64
)
size
.
width
*
(
uint64
)
size
.
height
;
uint64
pixels
=
(
uint64
)
size
.
width
*
(
uint64
)
size
.
height
;
CV_Assert
(
pixels
<=
CV_IO_MAX_IMAGE_PIXELS
);
CV_Assert
(
pixels
<=
CV_IO_MAX_IMAGE_PIXELS
);
return
size
;
return
size
;
...
@@ -998,7 +999,7 @@ cvSaveImage( const char* filename, const CvArr* arr, const int* _params )
...
@@ -998,7 +999,7 @@ cvSaveImage( const char* filename, const CvArr* arr, const int* _params )
if
(
_params
)
if
(
_params
)
{
{
for
(
;
_params
[
i
]
>
0
;
i
+=
2
)
for
(
;
_params
[
i
]
>
0
;
i
+=
2
)
CV_Assert
(
i
<
CV_IO_MAX_IMAGE_PARAMS
*
2
);
// Limit number of params for security reasons
CV_Assert
(
static_cast
<
size_t
>
(
i
)
<
cv
::
CV_IO_MAX_IMAGE_PARAMS
*
2
);
// Limit number of params for security reasons
}
}
return
cv
::
imwrite_
(
filename
,
cv
::
cvarrToMat
(
arr
),
return
cv
::
imwrite_
(
filename
,
cv
::
cvarrToMat
(
arr
),
i
>
0
?
std
::
vector
<
int
>
(
_params
,
_params
+
i
)
:
std
::
vector
<
int
>
(),
i
>
0
?
std
::
vector
<
int
>
(
_params
,
_params
+
i
)
:
std
::
vector
<
int
>
(),
...
@@ -1029,7 +1030,7 @@ cvEncodeImage( const char* ext, const CvArr* arr, const int* _params )
...
@@ -1029,7 +1030,7 @@ cvEncodeImage( const char* ext, const CvArr* arr, const int* _params )
if
(
_params
)
if
(
_params
)
{
{
for
(
;
_params
[
i
]
>
0
;
i
+=
2
)
for
(
;
_params
[
i
]
>
0
;
i
+=
2
)
CV_Assert
(
i
<
CV_IO_MAX_IMAGE_PARAMS
*
2
);
// Limit number of params for security reasons
CV_Assert
(
static_cast
<
size_t
>
(
i
)
<
cv
::
CV_IO_MAX_IMAGE_PARAMS
*
2
);
// Limit number of params for security reasons
}
}
cv
::
Mat
img
=
cv
::
cvarrToMat
(
arr
);
cv
::
Mat
img
=
cv
::
cvarrToMat
(
arr
);
if
(
CV_IS_IMAGE
(
arr
)
&&
((
const
IplImage
*
)
arr
)
->
origin
==
IPL_ORIGIN_BL
)
if
(
CV_IS_IMAGE
(
arr
)
&&
((
const
IplImage
*
)
arr
)
->
origin
==
IPL_ORIGIN_BL
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment