PHPackages                             framixa-com/bulletproof - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. framixa-com/bulletproof

ActiveLibrary[Image &amp; Media](/categories/media)

framixa-com/bulletproof
=======================

A simple and secure PHP image uploader

03PHP

Since Sep 19Pushed 8mo agoCompare

[ Source](https://github.com/framixa-com/bulletproof)[ Packagist](https://packagist.org/packages/framixa-com/bulletproof)[ RSS](/packages/framixa-com-bulletproof/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

BULLETPROOF [![Test](https://github.com/samayo/bulletproof/actions/workflows/php.yml/badge.svg)](https://github.com/samayo/bulletproof/actions/workflows/php.yml)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#bulletproof-)

[![Latest Stable Version](https://camo.githubusercontent.com/7c2397804f9b74c61f185a6df4efa50746ed43d3fde4d97507c208e2bea3e53a/68747470733a2f2f706f7365722e707567782e6f72672f73616d61796f2f62756c6c657470726f6f662f762f737461626c652e7376673f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/samayo/bulletproof) [![Total Downloads](https://camo.githubusercontent.com/b21fe68c9c652b7c00be349447a58e4c0ebbdc2e1d9ac5ea66634fe1e58a42c6/68747470733a2f2f706f7365722e707567782e6f72672f73616d61796f2f62756c6c657470726f6f662f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/samayo/bulletproof?format=flat-square) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/96cde15912426553c02d1b76f52799410268ec1a10935e58b2c01bc91a6404ea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d61796f2f62756c6c657470726f6f662f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samayo/bulletproof/?branch=master) [![License](https://camo.githubusercontent.com/7b4eec066c6142a6d56b4869a7bbf95fb51e0c49ce08dd629ed235db8d098c76/68747470733a2f2f706f7365722e707567782e6f72672f73616d61796f2f62756c6c657470726f6f662f6c6963656e7365)](https://packagist.org/packages/fastpress/framework)

Bulletproof is a single-class PHP library to upload images securely.

Installation
------------

[](#installation)

Install using git

```
$ git clone https://github.com/samayo/bulletproof.git
```

Install using Composer

```
$ composer require samayo/bulletproof:5.0.*
```

Or [download it manually](https://github.com/samayo/bulletproof/releases) in a ZIP format

Usage
-----

[](#usage)

To quickly upload images, use the following HTML &amp; PHP code:

```

```

```
require_once  "path/to/bulletproof.php";

$image = new Bulletproof\Image($_FILES);

if($image["pictures"]){
  $upload = $image->upload();

  if($upload){
    echo $upload->getPath(); // uploads/cat.gif
  }else{
    echo $image->getError();
  }
}
```

For more options or configurations, check the following examples:

Configs
-------

[](#configs)

#### Setting Properties

[](#setting-properties)

Methods to set restriction on the image name, size, type, etc.. to upload

```
// To provide a name for the image. If unused, image name will be auto-generated.
$image->setName($name);

// To set the min/max image size to upload (in bytes)
$image->setSize($min, $max);

// To define a list of allowed image types to upload
$image->setMime(array('jpeg', 'gif'));

// To set the max image height/width to upload (limit in pixels)
$image->setDimension($width, $height);

// To create a folder name to store the uploaded image, with optional chmod permission
$image->setStorage($folderName, $optionalPermission);
```

#### Getting Properties

[](#getting-properties)

Methods to retrieve image data before/after upload.

```
// To get the image name
$image->getName();

// To get the image size (in bytes)
$image->getSize();

// To get the image mime (extension)
$image->getMime();

// To get the image width in pixels
$image->getWidth();

// To get the image height in pixels
$image->getHeight();

// To get image location (folder where images are uploaded)
$image->getStorage();

// To get the full image path. ex 'images/logo.jpg'
$image->getPath();

// To get the json format value of all the above information
$image->getJson();
```

#### Extended Configuration Usage

[](#extended-configuration-usage)

How to use the property setters and getters.

```
$image = new Bulletproof\Image($_FILES);

$image->setName("samayo")
      ->setMime(["gif"])
      ->setStorage(__DIR__ . "/avatars");

if($image["pictures"]){
  if($image->upload()){
    echo $image->getName(); // samayo
    echo $image->getMime(); // gif
    echo $image->getStorage(); // avatars
    echo $image->getPath(); // avatars/samayo.gif
  }
}
```

#### Image Manipulation

[](#image-manipulation)

To crop, resize or watermak images, use functions stored in [`src/utils`](https://github.com/samayo/bulletproof/tree/master/src/utils)

#### Creating custom errors

[](#creating-custom-errors)

Use php exceptions to define custom error responses

```
if($image['pictures']){
  try {
    if($image->getMime() !== 'png'){
      throw new \Exception('Only PNG image types are allowed');
    }

    // check size, width, height...

    if(!$image->upload()){
      throw new \Exception($image->getError());
    } else {
      echo $image->getPath();
    }

  } catch (\Exception $e){
    echo "Error " . $e->getMessage();
  }
}
```

#### What makes this secure?

[](#what-makes-this-secure)

- Uses **[`exif_imagetype()`](https://php.net/manual/function.exif-imagetype.php)** to get the true image mime (`.extension`)
- Uses **[`getimagesize()`](https://php.net/manual/function.getimagesize.php)** to check if image has a valid height / width in pixels.
- Sanitized images names, strict folder permissions and more...

### License: MIT

[](#license-mit)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance43

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/78face8a4bd017982565d46d9ba214107cd542684c61155b4c9948392d45e179?d=identicon)[only1Enes](/maintainers/only1Enes)

---

Top Contributors

[![samayo](https://avatars.githubusercontent.com/u/5304093?v=4)](https://github.com/samayo "samayo (182 commits)")[![LorincJuraj](https://avatars.githubusercontent.com/u/18634191?v=4)](https://github.com/LorincJuraj "LorincJuraj (6 commits)")[![fmkoc](https://avatars.githubusercontent.com/u/42084115?v=4)](https://github.com/fmkoc "fmkoc (5 commits)")[![lordgiotto](https://avatars.githubusercontent.com/u/5115382?v=4)](https://github.com/lordgiotto "lordgiotto (3 commits)")[![only1Enes](https://avatars.githubusercontent.com/u/58430165?v=4)](https://github.com/only1Enes "only1Enes (3 commits)")[![progsource](https://avatars.githubusercontent.com/u/1206026?v=4)](https://github.com/progsource "progsource (1 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (1 commits)")[![tadhgboyle](https://avatars.githubusercontent.com/u/26070412?v=4)](https://github.com/tadhgboyle "tadhgboyle (1 commits)")[![BitConf](https://avatars.githubusercontent.com/u/9640081?v=4)](https://github.com/BitConf "BitConf (1 commits)")[![thorsten](https://avatars.githubusercontent.com/u/45284?v=4)](https://github.com/thorsten "thorsten (1 commits)")[![crumpetcrusher](https://avatars.githubusercontent.com/u/5601386?v=4)](https://github.com/crumpetcrusher "crumpetcrusher (1 commits)")[![effu](https://avatars.githubusercontent.com/u/1723287?v=4)](https://github.com/effu "effu (1 commits)")[![fiil](https://avatars.githubusercontent.com/u/7559777?v=4)](https://github.com/fiil "fiil (1 commits)")[![Mknsri](https://avatars.githubusercontent.com/u/5314500?v=4)](https://github.com/Mknsri "Mknsri (1 commits)")

### Embed Badge

![Health badge](/badges/framixa-com-bulletproof/health.svg)

```
[![Health](https://phpackages.com/badges/framixa-com-bulletproof/health.svg)](https://phpackages.com/packages/framixa-com-bulletproof)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
