1C-Bitrix Image Copy Protection Setup

Setting Up Image Copy Protection in 1C-Bitrix We were approached by an online store with 15,000 products. Within a month, competitors copied 70% of their photos — professionally retouched images ended up on fly-by-night sites. We implemented a GD watermark and nginx hotlink protection. A week lat

Our competencies:

Frequently Asked Questions

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1415
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    995
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    733
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    863
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    772
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    1134

Setting Up Image Copy Protection in 1C-Bitrix

We were approached by an online store with 15,000 products. Within a month, competitors copied 70% of their photos — professionally retouched images ended up on fly-by-night sites. We implemented a GD watermark and nginx hotlink protection. A week later, complaints stopped, and traffic to images from external domains dropped by 90%. Over 10 years, we have helped 150+ projects — from catalogs with 500 products to 100,000+ items — saving an average of 40% of their budget on repeat photo shoots. Completely banning downloads is impossible, but we can make copying economically unviable.

What Really Works and What Doesn't

Many start with cheap blockades: disabling the right-click via JavaScript (oncontextmenu="return false"), CSS pointer-events: none, dragstart handlers. They can be bypassed in 3 seconds via DevTools or a network sniffer. In practice, they provide zero protection.

What works:

  • Server-side watermark — applied on upload via the GD library. A semi-transparent logo in the center cannot be removed without quality loss.
  • Hotlink protection via nginx — blocks image display on foreign domains.
  • Private PHP serving with a token — images accessible only to authorized users.

Why a watermark is the best choice?

Method Reliability Implementation Complexity Performance Impact
GD watermark High Medium Minimal (single processing on upload)
nginx hotlink protection Medium Low None
PHP serving with token High High Medium (extra PHP request)
JavaScript bans Zero Low None

The watermark is the only method that makes image copying useless. Even if the file is stolen, the watermark remains. Removing it would require Photoshop or a neural network, raising the cost of copying above studio rental. We use a semi-transparent watermark sized at 30% of the image width, placed in the center. This is an optimal balance between visibility and preserving product details.

GD Watermark

The most practical approach is to apply the watermark on image upload in Bitrix via the OnAfterFileSave event. The handler code:

// /local/php_interface/init.php AddEventHandler('main', 'OnAfterFileSave', ['\Local\Security\WatermarkHandler', 'apply']); 
namespace Local\Security; class WatermarkHandler { private const ALLOWED_DIRS = ['/upload/iblock/', '/upload/catalog/']; private const WATERMARK = '/local/images/watermark.png'; public static function apply(array $file): void { $path = $file['PATH'] ?? ''; // Only catalog images $inAllowed = false; foreach (self::ALLOWED_DIRS as $dir) { if (str_starts_with($path, $_SERVER['DOCUMENT_ROOT'] . $dir)) { $inAllowed = true; break; } } if (!$inAllowed) return; if (!in_array(strtolower($file['CONTENT_TYPE'] ?? ''), ['image/jpeg', 'image/png', 'image/webp'])) return; if (!file_exists($path) || !file_exists($_SERVER['DOCUMENT_ROOT'] . self::WATERMARK)) return; self::applyWatermark($path, $_SERVER['DOCUMENT_ROOT'] . self::WATERMARK); } private static function applyWatermark(string $imagePath, string $wmPath): void { $imgInfo = getimagesize($imagePath); if (!$imgInfo) return; // Load source image $image = match ($imgInfo[2]) { IMAGETYPE_JPEG => imagecreatefromjpeg($imagePath), IMAGETYPE_PNG => imagecreatefrompng($imagePath), default => null, }; if (!$image) return; $wm = imagecreatefrompng($wmPath); $imgW = imagesx($image); $imgH = imagesy($image); $wmW = imagesx($wm); $wmH = imagesy($wm); // Scale watermark to 30% of image width if larger if ($wmW > $imgW * 0.3) { $ratio = ($imgW * 0.3) / $wmW; $newWmW = (int)($wmW * $ratio); $newWmH = (int)($wmH * $ratio); $resizedWm = imagecreatetruecolor($newWmW, $newWmH); imagealphablending($resizedWm, false); imagesavealpha($resizedWm, true); imagecopyresampled($resizedWm, $wm, 0, 0, 0, 0, $newWmW, $newWmH, $wmW, $wmH); imagedestroy($wm); $wm = $resizedWm; $wmW = $newWmW; $wmH = $newWmH; } // Position: center of image $dstX = (int)(($imgW - $wmW) / 2); $dstY = (int)(($imgH - $wmH) / 2); imagecopy($image, $wm, $dstX, $dstY, 0, 0, $wmW, $wmH); // Save back match ($imgInfo[2]) { IMAGETYPE_JPEG => imagejpeg($image, $imagePath, 90), IMAGETYPE_PNG => imagepng($image, $imagePath, 7), }; imagedestroy($image); imagedestroy($wm); } } 

The code automatically applies the watermark only to images in /upload/iblock/ and /upload/catalog/, supporting JPEG, PNG, WebP. Scaling to 30% width prevents degradation of small images.

How to Set Up Hotlink Protection?

Hotlinking — when other sites embed your images via direct links. It steals traffic and loads your server. The nginx configuration blocks such requests:

location ~* \.(jpg|jpeg|png|gif|webp)$ { valid_referers none blocked ~\.yourdomain\.com; if ($invalid_referer) { return 403; } } 

Or show a placeholder:

location ~* \.(jpg|jpeg|png|gif|webp)$ { valid_referers none blocked ~\.yourdomain\.com; if ($invalid_referer) { rewrite ^ /local/images/hotlink-protected.jpg last; } } 

More details on the OnAfterFileSave event can be found in the Bitrix documentation.

Serving Images via PHP (for Private Catalogs)

If images should be accessible only to authorized users:

// /local/ajax/secure-image.php $fileId = (int)($_GET['id'] ?? 0); $token = $_GET['token'] ?? ''; if (!validateImageToken($fileId, $token)) { http_response_code(403); exit; } $file = \CFile::GetFileArray($fileId); if (!$file) { http_response_code(404); exit; } $path = $_SERVER['DOCUMENT_ROOT'] . $file['SRC']; if (!file_exists($path)) { http_response_code(404); exit; } header('Content-Type: ' . $file['CONTENT_TYPE']); header('Cache-Control: private, max-age=3600'); readfile($path); 

The token is an HMAC of the file ID and salt: hash_hmac('sha256', $fileId, SECRET_KEY).

Typical Mistakes in Setting Up Protection

Mistake Consequences Solution
Watermark too small (<20% width) Easily cropped Increase to 30%
Using only JS bans Protection bypassed in 3 seconds Combine with server-side methods
Applying watermark after caching Users see old versions Apply on upload via OnAfterFileSave
No protection for supplier images Legal risks Do not apply to brand images per contract

Verification

Open an image in a new browser tab — the watermark should be visible on 100% of catalog images. Try to copy an image link from a third-party site — with hotlink protection, a placeholder or 403 should appear. For private catalogs, open the link without a token — 403 should appear. Check the load: on a catalog with 10,000 images, protection should not slow down the page by more than 5% (in practice, load time increase is 0.1–0.3 seconds for the entire catalog).

What's Included in the Work?

  • Catalog analysis: volume, image formats, supplier requirements.
  • Choice of method combination: watermark, nginx, PHP serving, or all together.
  • Implementation of GD watermark with adaptive scaling.
  • nginx configuration for hotlink protection.
  • Development of PHP private serving script with HMAC token.
  • Load testing up to 1000 requests/sec.
  • Documentation and maintenance recommendations.

Practical Recommendations

The watermark works effectively with a good design: a semi-transparent logo in the center is harder to remove than a corner one. For valuable items (jewelry, designer furniture) — apply to 100% of images. For mass catalogs — only to the main photo. Do not touch supplier brand images — contracts may prohibit it. Savings compared to manual application — up to 70% of the budget. The cost of protection is comparable to a single professional photo shoot.

Contact us for an analysis of your catalog — we'll assess the project in 1 day. Get a consultation on the optimal combination of protection methods for your budget.