Download the PHP package buonzz/scalp without Composer
On this page you can find all versions of the php package buonzz/scalp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package scalp
Short Description Command line tool to Analyze and store your Media file's metadata
License MIT
Informations about the package scalp
Scalp
Command line tool to Analyze and store your Media file's metadata.
Do you or your organization have a bunch of images/videos lumped into some hard drive? If those are stored in a non-structured way, like there is no real scheme on how it is organized (by date, by album etc). Performing analysis and retrieving a certain set of files will be really tough to do.
Scalp allows you analyze and extract a lot of information from those bunch of media files and build "something" out of that data. It is purely a backend tool that is designed to support any kind of application you might be developing on that top of the extracted info.
Few situations it could be useful:
- Build a private Search engine, that allows user to input certain keywords and return a list of files matching that keyword
- Use as a backend store for your CMS
- Generate thumbnails (small/medium/large) and host the processed files to CDN
Below is the overview of how Scalp works
- Your media files can be stored in the same server or a dedicated NAS server (needs to be mounted to a location where scalp can access it )
- Scalp reads the files and extract Metadata from it (represented as JSON object)
- Scalp generates thumbnails (small/medium/large)
- The data processed can then be forwarded to any of the supported backend storage (File, ElasticSearch, S3, BackBlaze etc)
- Your application accesses the processed data via those backend storage
Advantages
- You can continously re-organize how the files is presented to your users without having to physically move around the actual files. Since the representation can be abstracted by the Application itself
- Your raw images/videos is left untouched (Scalp never move, resize or modify its properties)
- Saves a lot of bandwidth, since instead of serving the raw images while browsing items. You can just use the thumbnails created by Scalp. and only access the raw (usually big file) image when user requested.
Requirements
- Linux-based Server (Debian/RHEL etc)
- PHP 5.4 or greater
Install
It is very easy to install Scalp as a CLI utility:
via wget
via curl
After this, scalp command is available anywhere in your computer. To check if the scalp is installed properly, just execute
This should output
via Composer - Globally
You can install scalp globally in your machine:
Simply add this directory to your PATH in your ~/.bash_profile (or ~/.bashrc) like this:
via Composer - per-project
just require the buonzz/scalp in your composer project
Usage
Scalp can extract the metadata information from your media files and export it to following:
- Static JSON files
- Thumbnails
First, you need to create a configuration file called .env This will be used by scalp to retrieve certain information:
Setting | Description | Default |
---|---|---|
INPUT_FOLDER | the folder on which to read the files to analyze | current folder |
OUTPUT_FOLDER | where to dump the JSON files / thumbnails | dist |
THUMB_PERCENT_RESIZE | Used when creating thumbnails, this should be between 10-100, the images will be resized with this percent value | 10 |
Metadata Extraction
To generate static JSON files
Sample extracted metadata
Thumbnail Creation
Running in the background
If you got a relatively large collection of media files. It might take hours for the process to complete. You can place the process in the background, so that it will continue to execute even after you had logged out in the terminal.
Backend Storage
The processed data can be stored in multitude of ways. Allowing you to freely use its data in whatever purpose it may serve for your use-case.
File
The simpliest backend is the file storage. It simply dumps everything to whatever you had defined in the OUTPUT_FOLDER configuration in your .env file. You can either use the generated files and host it to your web server/CDN or pass it to your application for further processing.
ElasticSearch
When using ElasticSearch as a backend. Make sure to provide the following entries in your .env file
Setting | Description | Default |
---|---|---|
DB_HOSTNAME | database hostname for the ElasticSearch Server | localhost |
DB_NAME | index name of the documents in ElasticSearch | metadata |
DOC_TYPE | the document type in ES (table name for RDBMS) | files |
DB_PORT | port number for ES | 9200 |
DB_USER | username for the database | null |
DB_PASSWORD | database password | null |
LOG_FOLDER | where to write the log file, this is the log file generated by ElasticSearch client. Useful in debugging | logs |
Load it to ElasticSearch
Save thumbnails to ElasticSearch
Viewing the thumbnails
You can get a preview of those thumbnails by using the PHP's built in web server
then in your localhost, just append the url given by search command.
BackBlaze's B2 Cloud Storage
B2 is a great way to store both your metadata and thumbnails if you plan to serve those data in a web site with high traffic. It is way cheaper than the other alternative, plus it offers you a free 10GB initial storage so you don't really need to pay anything unless you decide to upload more contents.
Provide the following entries in your .env file prior to using the BackBlaze
Setting | Value |
---|---|
B2_ACCOUNT_ID | your BackBlaze account ID |
B2_APPLICATION_KEY | Application key for your account |
Then execute the following to extract, create thumbnail and upload the data to B2:
the first parameter (scalp-test) is the bucket name you created in your backblaze account, and the second parameter is the folder where the files to be uploaded is located.
AWS S3
TODO
All versions of scalp with dependencies
vlucas/phpdotenv Version ^2.2
symfony/console Version ^3.0
james-heinrich/getid3 Version 1.9.*
monolog/monolog Version ^1.19
masterexploder/phpthumb Version ^2.1
symfony/stopwatch Version ^3.0
guzzlehttp/guzzle Version ^6.2
cwhite92/b2-sdk-php Version ^1.2