Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
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
die_coolen_jungs
our_own_cloud_project
Commits
186c6a56
Commit
186c6a56
authored
11 years ago
by
Frank Karlitschek
Browse files
Options
Downloads
Plain Diff
Merge pull request #4949 from owncloud/improve_unknown_preview_backend
use svg to generate filetype icon if imagick available
parents
d70a6c3f
19ea4f79
Loading
Loading
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/preview/provider.php
+9
-3
9 additions, 3 deletions
lib/private/preview/provider.php
lib/private/preview/unknown.php
+24
-2
24 additions, 2 deletions
lib/private/preview/unknown.php
with
33 additions
and
5 deletions
lib/private/preview/provider.php
+
9
−
3
View file @
186c6a56
...
@@ -11,9 +11,15 @@ abstract class Provider {
...
@@ -11,9 +11,15 @@ abstract class Provider {
abstract
public
function
getMimeType
();
abstract
public
function
getMimeType
();
/**
/**
* search for $query
* get thumbnail for file at path $path
* @param string $query
* @param string $path Path of file
* @return
* @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
* @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
* @param bool $scalingUp Disable/Enable upscaling of previews
* @param object $fileview fileview object of user folder
* @return mixed
* false if no preview was generated
* OC_Image object of the preview
*/
*/
abstract
public
function
getThumbnail
(
$path
,
$maxX
,
$maxY
,
$scalingup
,
$fileview
);
abstract
public
function
getThumbnail
(
$path
,
$maxX
,
$maxY
,
$scalingup
,
$fileview
);
}
}
This diff is collapsed.
Click to expand it.
lib/private/preview/unknown.php
+
24
−
2
View file @
186c6a56
...
@@ -20,8 +20,30 @@ class Unknown extends Provider {
...
@@ -20,8 +20,30 @@ class Unknown extends Provider {
$path
=
\OC_Helper
::
mimetypeIcon
(
$mimetype
);
$path
=
\OC_Helper
::
mimetypeIcon
(
$mimetype
);
$path
=
\OC
::
$SERVERROOT
.
substr
(
$path
,
strlen
(
\OC
::
$WEBROOT
));
$path
=
\OC
::
$SERVERROOT
.
substr
(
$path
,
strlen
(
\OC
::
$WEBROOT
));
return
new
\OC_Image
(
$path
);
$svgPath
=
substr_replace
(
$path
,
'svg'
,
-
3
);
if
(
extension_loaded
(
'imagick'
)
&&
file_exists
(
$svgPath
))
{
// http://www.php.net/manual/de/imagick.setresolution.php#85284
$svg
=
new
\Imagick
();
$svg
->
readImage
(
$svgPath
);
$res
=
$svg
->
getImageResolution
();
$x_ratio
=
$res
[
'x'
]
/
$svg
->
getImageWidth
();
$y_ratio
=
$res
[
'y'
]
/
$svg
->
getImageHeight
();
$svg
->
removeImage
();
$svg
->
setResolution
(
$maxX
*
$x_ratio
,
$maxY
*
$y_ratio
);
$svg
->
setBackgroundColor
(
new
\ImagickPixel
(
'transparent'
));
$svg
->
readImage
(
$svgPath
);
$svg
->
setImageFormat
(
'png32'
);
$image
=
new
\OC_Image
();
$image
->
loadFromData
(
$svg
);
}
else
{
$image
=
new
\OC_Image
(
$path
);
}
return
$image
;
}
}
}
}
\OC\Preview
::
registerProvider
(
'OC\Preview\Unknown'
);
\OC\Preview
::
registerProvider
(
'OC\Preview\Unknown'
);
\ No newline at end of file
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