Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
vMap
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marty Fabien
vMap
Commits
5abc6530
Commit
5abc6530
authored
Mar 7, 2019
by
Armand Bahi
Browse files
Options
Downloads
Patches
Plain Diff
Redimentionnement des images sans déformation
parent
baf27eb6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
vas/rest/class/vmlib/files/Files_manager.class.inc
+65
-28
65 additions, 28 deletions
vas/rest/class/vmlib/files/Files_manager.class.inc
vas/rest/conf/properties_server.inc
+2
-2
2 additions, 2 deletions
vas/rest/conf/properties_server.inc
with
67 additions
and
30 deletions
vas/rest/class/vmlib/files/Files_manager.class.inc
+
65
−
28
View file @
5abc6530
...
...
@@ -259,6 +259,70 @@ class Files_manager{
return
$aFileStruc
;
}
/**
* Upload la miniature du fichier si il s'agit l'image ou retourne false
*
* @param {array} $aFileStruct Structure du fichier
* @param {string} $sDestPath Répertoire de destination
* @param {string} $sField Champ en base de données
* @param {string} $sMinDestPath Répertoire de destination du fichier min
* @param {integer} $iMaxSize Taille maximale du fichier
* @return {boolean} true en cas de succes
*/
private
function
uploadImageThumbnail
(
$aFileStruct
,
$sDestPath
,
$sField
,
$sMinDestPath
,
$iMaxSize
=
-
1
)
{
$aImgSize
=
getimagesize
(
$aFileStruct
[
'tmp_name'
]);
// Si image
if
(
@
is_array
(
$aImgSize
)){
$aThumbnailFileStruct
=
$aFileStruct
;
$aThumbnailFileStruct
[
"width"
]
=
200
;
$aThumbnailFileStruct
[
"height"
]
=
200
;
if
(
is_int
(
$this
->
oProperties
[
'filesystem_thumbnails_max_width'
])
&&
is_int
(
$this
->
oProperties
[
'filesystem_thumbnails_max_height'
]))
{
$imgWidth
=
$aImgSize
[
0
];
$imgHeight
=
$aImgSize
[
1
];
// Redimentionne la largeur en conservant le ratio
if
(
$imgWidth
>
$this
->
oProperties
[
'filesystem_thumbnails_max_width'
])
{
$imgHeight
=
round
(
$imgHeight
*
$this
->
oProperties
[
'filesystem_thumbnails_max_width'
]
/
$imgWidth
);
$imgWidth
=
$this
->
oProperties
[
'filesystem_thumbnails_max_width'
];
}
// Redimentionne la hauteur en conservant le ratio
if
(
$imgHeight
>
$this
->
oProperties
[
'filesystem_thumbnails_max_height'
])
{
$imgWidth
=
round
(
$imgWidth
*
$this
->
oProperties
[
'filesystem_thumbnails_max_height'
]
/
$imgHeight
);
$imgHeight
=
$this
->
oProperties
[
'filesystem_thumbnails_max_height'
];
}
$aThumbnailFileStruct
[
"height"
]
=
$imgHeight
;
$aThumbnailFileStruct
[
"width"
]
=
$imgWidth
;
}
$aThumbnailFileStruct
[
'tmp_name'
]
=
$aThumbnailFileStruct
[
'tmp_name'
]
.
'.min'
;
$aDestPathExt
=
explode
(
'.'
,
$sDestPath
);
$aDestPathExt
=
explode
(
'.'
,
$sDestPath
);
// Ajoute .min sur la destination
array_splice
(
$aDestPathExt
,
-
1
,
0
,
'min'
);
$sMinDestPath
=
implode
(
'.'
,
$aDestPathExt
);
// Copie le fichier dans tmp
copy
(
$aFileStruct
[
'tmp_name'
],
$aThumbnailFileStruct
[
'tmp_name'
]);
// Upload le fichier .min.jpg
$this
->
uploadFile
(
$sField
,
"image"
,
$sMinDestPath
,
$iMaxSize
,
$aThumbnailFileStruct
);
return
true
;
}
else
{
return
false
;
}
}
/**
*This method upload a file in ws_data.
*@param $sModule Name of the module.
...
...
@@ -356,34 +420,7 @@ class Files_manager{
// Image miniature
$sMinDestPath
=
null
;
if
(
$bCreateThumbnail
===
true
&&
file_exists
(
$aFileStruct
[
'tmp_name'
]))
{
// Si image
if
(
@
is_array
(
getimagesize
(
$aFileStruct
[
'tmp_name'
]))){
$aThumbnailFileStruct
=
$aFileStruct
;
$aThumbnailFileStruct
[
"width"
]
=
200
;
$aThumbnailFileStruct
[
"height"
]
=
200
;
if
(
is_int
(
$this
->
oProperties
[
'filesystem_thumbnails_width'
]))
{
$aThumbnailFileStruct
[
"width"
]
=
$this
->
oProperties
[
'filesystem_thumbnails_width'
];
}
if
(
is_int
(
$this
->
oProperties
[
'filesystem_thumbnails_height'
]))
{
$aThumbnailFileStruct
[
"height"
]
=
$this
->
oProperties
[
'filesystem_thumbnails_height'
];
}
$aThumbnailFileStruct
[
'tmp_name'
]
=
$aThumbnailFileStruct
[
'tmp_name'
]
.
'.min'
;
$aDestPathExt
=
explode
(
'.'
,
$sDestPath
);
// Ajoute .min sur la destination
array_splice
(
$aDestPathExt
,
-
1
,
0
,
'min'
);
$sMinDestPath
=
implode
(
'.'
,
$aDestPathExt
);
// Copie le fichier dans tmp
copy
(
$aFileStruct
[
'tmp_name'
],
$aThumbnailFileStruct
[
'tmp_name'
]);
// Upload le fichier .min.jpg
$this
->
uploadFile
(
$sField
,
"image"
,
$sMinDestPath
,
$iMaxSize
,
$aThumbnailFileStruct
);
}
$this
->
uploadImageThumbnail
(
$aFileStruct
,
$sDestPath
,
$sField
,
$sMinDestPath
,
$iMaxSize
);
}
// Upload du fichier
...
...
This diff is collapsed.
Click to expand it.
vas/rest/conf/properties_server.inc
+
2
−
2
View file @
5abc6530
...
...
@@ -49,8 +49,8 @@ $properties["notifierAccessKeyAccount"] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$properties
[
"notifierSecretKeyAccount"
]
=
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
;
// utilisation de s3 pour remplacer le système de Fichier
$properties
[
'filesystem'
]
=
'fs'
;
// s3
$properties
[
'filesystem_thumbnails_width'
]
=
350
;
// taille des images .min.jpg
$properties
[
'filesystem_thumbnails_height'
]
=
350
;
// taille des images .min.jpg
$properties
[
'filesystem_thumbnails_
max_
width'
]
=
350
;
// taille
maximale
des images .min.jpg
$properties
[
'filesystem_thumbnails_
max_
height'
]
=
350
;
// taille
maximale
des images .min.jpg
$properties
[
'AWSCredentialsFilePath'
]
=
""
;
// .../.aws/credentials
$properties
[
"fileS3UploaderProfil"
]
=
""
;
$properties
[
"fileS3UploaderBucket"
]
=
""
;
...
...
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