Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchParapheur
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchParapheur
Commits
1d4fe68d
Verified
Commit
1d4fe68d
authored
4 years ago
by
Florian Azizian
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #15565 TIME 2:45 Improve performance for image convertion
parent
6693286a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/convert/controllers/ConvertThumbnailController.php
+28
-10
28 additions, 10 deletions
src/app/convert/controllers/ConvertThumbnailController.php
src/app/convert/scripts/ThumbnailScript.php
+2
-2
2 additions, 2 deletions
src/app/convert/scripts/ThumbnailScript.php
with
30 additions
and
12 deletions
src/app/convert/controllers/ConvertThumbnailController.php
+
28
−
10
View file @
1d4fe68d
...
@@ -17,6 +17,7 @@ namespace Convert\controllers;
...
@@ -17,6 +17,7 @@ namespace Convert\controllers;
use
Docserver\controllers\DocserverController
;
use
Docserver\controllers\DocserverController
;
use
Docserver\models\AdrModel
;
use
Docserver\models\AdrModel
;
use
Docserver\models\DocserverModel
;
use
Docserver\models\DocserverModel
;
use
setasign\Fpdi\Tcpdf\Fpdi
;
use
SrcCore\models\CoreConfigModel
;
use
SrcCore\models\CoreConfigModel
;
use
SrcCore\models\ValidatorModel
;
use
SrcCore\models\ValidatorModel
;
...
@@ -61,9 +62,18 @@ class ConvertThumbnailController
...
@@ -61,9 +62,18 @@ class ConvertThumbnailController
$filename
=
pathinfo
(
$pathToDocument
,
PATHINFO_FILENAME
);
$filename
=
pathinfo
(
$pathToDocument
,
PATHINFO_FILENAME
);
$tmpPath
=
CoreConfigModel
::
getTmpPath
();
$tmpPath
=
CoreConfigModel
::
getTmpPath
();
$img
=
new
\Imagick
();
if
(
!
empty
(
$args
[
'configPath'
]))
{
$img
->
pingImage
(
$pathToDocument
);
$configPath
=
$args
[
'configPath'
];
$pageCount
=
$img
->
getNumberImages
();
}
else
{
$configPath
=
CoreConfigModel
::
getConfigPath
();
}
$overrideFile
=
"
{
$configPath
}
/override/setasign/fpdi_pdf-parser/src/autoload.php"
;
if
(
file_exists
(
$overrideFile
))
{
require_once
(
$overrideFile
);
}
$pdf
=
new
Fpdi
(
'P'
,
'pt'
);
$pageCount
=
$pdf
->
setSourceFile
(
$pathToDocument
);
$i
=
0
;
$i
=
0
;
while
(
$i
<
$pageCount
)
{
while
(
$i
<
$pageCount
)
{
...
@@ -137,16 +147,24 @@ class ConvertThumbnailController
...
@@ -137,16 +147,24 @@ class ConvertThumbnailController
return
[
'errors'
=>
'Document not found on docserver or not readable'
];
return
[
'errors'
=>
'Document not found on docserver or not readable'
];
}
}
$filename
=
pathinfo
(
$pathToDocument
,
PATHINFO_FILENAME
);
if
(
!
empty
(
$args
[
'configPath'
]))
{
$tmpPath
=
CoreConfigModel
::
getTmpPath
();
$configPath
=
$args
[
'configPath'
];
}
else
{
$configPath
=
CoreConfigModel
::
getConfigPath
();
}
$img
=
new
\Imagick
();
$overrideFile
=
"
{
$configPath
}
/override/setasign/fpdi_pdf-parser/src/autoload.php"
;
$img
->
pingImage
(
$pathToDocument
);
if
(
file_exists
(
$overrideFile
))
{
$pageCount
=
$img
->
getNumberImages
();
require_once
(
$overrideFile
);
}
$pdf
=
new
Fpdi
(
'P'
,
'pt'
);
$pageCount
=
$pdf
->
setSourceFile
(
$pathToDocument
);
if
(
$pageCount
<
$args
[
'page'
])
{
if
(
$pageCount
<
$args
[
'page'
])
{
return
[
'errors'
=>
'Page does not exist'
];
return
[
'errors'
=>
'Page does not exist'
];
}
}
$filename
=
pathinfo
(
$pathToDocument
,
PATHINFO_FILENAME
);
$tmpPath
=
CoreConfigModel
::
getTmpPath
();
$fileNameOnTmp
=
rand
()
.
$filename
;
$fileNameOnTmp
=
rand
()
.
$filename
;
$convertPage
=
$args
[
'page'
]
-
1
;
$convertPage
=
$args
[
'page'
]
-
1
;
...
@@ -199,9 +217,9 @@ class ConvertThumbnailController
...
@@ -199,9 +217,9 @@ class ConvertThumbnailController
exec
(
$command
.
' 2>&1'
,
$output
,
$return
);
exec
(
$command
.
' 2>&1'
,
$output
,
$return
);
if
(
$return
!==
0
)
{
if
(
$return
!==
0
)
{
return
"convert -density
5
00x
5
00 -quality 100
-background white -alpha remove
"
;
return
"convert -density
2
00x
2
00 -quality 100 "
;
}
else
{
}
else
{
return
"gm convert -density
5
00x
5
00 -quality 100
-background white +matte
"
;
return
"gm convert -density
2
00x
2
00 -quality 100"
;
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
src/app/convert/scripts/ThumbnailScript.php
+
2
−
2
View file @
1d4fe68d
...
@@ -46,9 +46,9 @@ class ThumbnailScript
...
@@ -46,9 +46,9 @@ class ThumbnailScript
]);
]);
if
(
isset
(
$args
[
'page'
]))
{
if
(
isset
(
$args
[
'page'
]))
{
$isConverted
=
ConvertThumbnailController
::
convertOnePage
([
'id'
=>
$args
[
'id'
],
'type'
=>
$args
[
'type'
],
'page'
=>
$args
[
'page'
]]);
$isConverted
=
ConvertThumbnailController
::
convertOnePage
([
'configPath'
=>
$args
[
'configPath'
],
'id'
=>
$args
[
'id'
],
'type'
=>
$args
[
'type'
],
'page'
=>
$args
[
'page'
]]);
}
else
{
}
else
{
$isConverted
=
ConvertThumbnailController
::
convert
([
'id'
=>
$args
[
'id'
],
'type'
=>
$args
[
'type'
]]);
$isConverted
=
ConvertThumbnailController
::
convert
([
'configPath'
=>
$args
[
'configPath'
],
'id'
=>
$args
[
'id'
],
'type'
=>
$args
[
'type'
]]);
}
}
if
(
!
empty
(
$isConverted
[
'errors'
]))
{
if
(
!
empty
(
$isConverted
[
'errors'
]))
{
DocumentModel
::
update
([
DocumentModel
::
update
([
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment