Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

327
Views
Add texture of img1 to img2 to get result img - Python / Javascript

I am trying to add texture and pattern of img1 to img2 to get result something like the result image img3 - Img2 is has transparent background and result Img3 must also have transparent background

Img1

Img2

Img3


about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Here is how to do that in Imagemagick. It can be done in Python/OpenCV, but I do not have the time now to implement it. It is pretty easy in Imagemagick using one of my bash shell scripts to do the spherize of the texture.

(I show how to do the spherical distortion in Python/OpenCV at How make eye and nose bigger or smaller in opencv and python in a previous post. And an example showing how to do the hard light composite in Python/OpenCV is in How to augment scanned document image with creases, folds and wrinkles?)

  • First, I have to trim the sphere image to its bounds and have it square dimensions.
  • Then I have to resize the texture image and crop it to the same dimensions as the trimmed sphere image.
  • Then I apply the spherize script to the cropped texture image
  • Finally I save the alpha channel from the sphere image and do a hardlight composite of the sphere image with the spherized texture image. And save the result

Sphere Image:

enter image description here

Texture Image:

enter image description here

convert sphere.png -trim +repage sphere_trim.png

convert texture.jpg -resize 1375x1375^ -gravity center -crop 1375x1375+0+0 +repage texture_resize_crop.jpg

spherize -a 1 -b white texture_resize_crop.jpg texture_resize_crop_spherize_a1.jpg

convert texture_resize_crop_spherize_a1.jpg \
sphere_trim.png \
\( +clone -alpha extract +write mpr:alpha +delete \) -alpha off \
\( +clone \) \
-compose hardlight -composite \
mpr:alpha -alpha off -compose over -compose copy_opacity -composite \
sphere_texture.png

Trimmed Sphere Image:

enter image description here

Resized and Cropped Texture Image:

enter image description here

Spherized Texture Image:

enter image description here

Result From Hardlight Composite:

enter image description here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!