1import{R as e}from"./app-XNeVM1Uh.js";import{B as t}from"./BlogPost-BJ57QaS3.js";import"./index-Djh9Lqgo.js";import"./proxy-BIgIZGNR.js";import"./arrow-up-DF5-Rmm1.js";import"./siteIdentity-CCvl92m1.js";import"./serializeJsonForHtml-CLBcjjNV.js";import"./BlogAuthor-D-P18xmC.js";import"./blogTaxonomy-u_7t0MAS.js";import"./calendar-BSaRyD4N.js";import"./refresh-cw-BY_xg12z.js";import"./chevron-left-HIA-KlHw.js";import"./share-2-nISwCrtH.js";import"./copy-CGuEYzUK.js";const a={audioUrl:"https://dropinblog.net/34249716/audio/hhphkw.mp3",author:{bio:"Aitor specialises in marketing analytics and data infrastructure, backed by 10 years of experience turning complex data into actionable performance insights. He writes practical guides to conversion tracking, Google Tag Manager and automating product feed tasks with Python.",bioLinks:[{text:"Google Tag Manager",url:"https://cleandigital.co.uk/blog/store-gclids-in-a-google-sheets-document-with-gtm"},{text:"automating product feed tasks with Python",url:"https://cleandigital.co.uk/blog/automate-image-color"}],name:"Aitor Larrañaga",photo:"https://dropinblog.net/cdn-cgi/image/fit=scale-down,width=600/34249716/authors/aitor_final.webp",profilePath:"/blog/authors/aitor-larranaga",role:"Contributor",slug:"aitor-larranaga",status:"contributor"},canonicalUrl:"https://cleandigital.co.uk/blog/automate-image-color",categories:[{id:4090932352,slug:"tips",title:"Tips"},{id:3262843236,slug:"python",title:"Python"},{id:494982317,slug:"automation",title:"Automation"},{id:610847240,slug:"google-merchant-centre",title:"Google Merchant Centre"}],content:`<p><strong><span>We all know how important it is to have a healthy feed full of attributes that allows Google to perform better by improving matching relevancy. However, sometimes, information is missing in the feed for many different reasons; the backend is not ready to pull some attributes, the information is not available, etc. </span></strong></p>\r 2<p><span>This is what happens sometimes with the “color” attribute on <a href="https://www.google.com/intl/en_uk/retail/solutions/merchant-center/?mcsubid=gb-en-ha-mc-bk-c-mce%21o3">Merchant Centre</a>. If you run an e-commerce, Clothing & Apparel business for example, and have lots of product variants/colours, the “color” attribute becomes vitally important. If the product feed does not have this information readily available, and we are unable to get it from the platform (which would be the ideal scenario here!) we’ve outlined a way to automate the process and have the attributes </span><strong><span>ready in a matter of seconds</span><span>.</span></strong></p>\r 3<p><span>Export from BigQuery</span></p>\r 4<p><span>Using <a href="https://cloud.google.com/bigquery">BigQuery</a> data transfer service, we can pull a merchant centre export which enables us to see the number of disapproved products as well as all of the feed attributes. This comes handy to create dashboards monitoring the feeds’ health but also to create supplemental feeds to create custom labels, and in this case, </span><span>add new product attributes</span><span>. </span></p>\r 5<p><strong> </strong></p>\r 6<p><span><span><img class="dib-img-loading" loading="lazy" src="https://io.dropinblog.com/uploaded/blogs/34249716/files/automate-image-color-zyt0w.png" width="602" height="240" alt="Automate Color" decoding="async"></span></span></p>\r 7<p><strong> </strong></p>\r 8<p><span>Download Images</span></p>\r 9<p><span>Now we have all the feed attributes ready in BigQuery, we can pull out the “image_link” attribute. We need the image URLs to download the product images and process them later.</span></p>\r 10<p><span>The easiest way to download all the image URLs is through the </span><span>google-cloud-bigquery </span><span>or </span><span>pandas-gbq</span><span> library.</span></p>\r 11<p> </p>\r 12<p><span>After we get the list of URLs with a simple “Select” </span><a href="https://cloud.google.com/bigquery/docs/reference/libraries#client-libraries-usage-python"><span>SQL statement</span></a><span>, we can download the images using the </span><span>requests</span><span> library.</span></p>\r 13<p><span>Check the Colours</span></p>\r 14\r 15<p> </p>\r 16<p><span>Once we have our images ready, we need to use another two libraries to check the predominant colours in the image: </span><span>colorthief </span><span>and </span><span>webcolors.</span></p>\r 17<p> </p>\r 18<p><span>For instance, if we have this image:</span></p>\r 19\r 20<p><span><span><img class="dib-img-loading" loading="lazy" src="https://io.dropinblog.com/uploaded/blogs/34249716/files/automate-image-color-ovot1.png" width="372" height="444" alt="Automate Color" decoding="async"></span></span></p>\r 21<p><strong> </strong></p>\r 22<p><span>The script is going to determine that the predominant colour in the picture is: darkslategrey. We can use that c
22olour as an attribute or we can do further maths to extract the predominant color on the “dark slate grey” which in this case can be either green or blue (both have, surprisingly, the same colour % mix).</span></p>\r 23\r 24<p><span>Send this info to Google Sheets</span></p>\r 25<p> </p>\r 26<p><span>After you choose whether you want to push a basic colour or the darkslategrey, we can easily send the information to a google sheets spreadsheet by using a library like </span><span>gspread </span><span>and have a supplemental feed mapping the ID to the newly extracted “color” attribute. </span></p>\r 27<p> </p>\r 28<p><span>I hope you can get an idea on how powerful data enrichment can be using the Merchants Data Transfer Service for BigQuery along with scripts like the one described throughout the article.</span></p>\r 29<p> </p>\r 30<p><span>To learn more about how to optimise your data feed and make the most of all the attributes available, <a href="https://us02web.zoom.us/webinar/register/WN_-GDaEF-cSme9JtkW6ib9ug">sign up to our Webinar</a></span><span> next Thursday 18th of May at 10am (BST).</span><a href="https://us02web.zoom.us/webinar/register/WN_-GDaEF-cSme9JtkW6ib9ug"></a></p>`,featuredImage:"https://dropinblog.net/cdn-cgi/image/fit=scale-down,format=auto,width=700/34249716/files/featured/Automate_Image_Color.png",id:623595332,keyword:"Automate Image Color",modifiedAt:"2023-05-11T10:46:00.000Z",noindex:!1,pinned:0,publishedAt:"2023-05-11T10:46:00.000Z",readtime:"3 minute read",related_posts:[{featuredImage:"https://dropinblog.net/cdn-cgi/image/fit=scale-down,format=auto,width=700/34249716/files/featured/Ad_Extensions.png",id:752856799,slug:"the-importance-of-ad-extensions",summary:"Paid advertising is a powerful digital marketing tool that can aid in attracting a desired audience to your website, enabling you to quickly drive",title:"Ad Extensions: Why Are They So Important?",url:"https://cleandigital.co.uk/blog/the-importance-of-ad-extensions"},{featuredImage:"https://dropinblog.net/cdn-cgi/image/fit=scale-down,format=auto,width=700/34249716/files/featured/Conversion_Rate.png",id:1347960872,slug:"from-browsers-to-buyers-how-to-improve-your-websites-conversion-rate",summary:"To summarise this blog with an overused metaphor: You can lead a horse customer to water your website but you cannot make them drink buy. Still here?",title:"From Browsers to Buyers: 4 Tips to Improve Your Website's Conversion Rate",url:"https://cleandigital.co.uk/blog/from-browsers-to-buyers-how-to-improve-your-websites-conversion-rate"},{featuredImage:"https://dropinblog.net/cdn-cgi/image/fit=scale-down,format=auto,width=700/34249716/files/featured/Customer_Personas.png",id:2902893229,slug:"mastering-your-market-with-customer-personas",summary:"There are many approaches to advertising, but a âone size fits allâ targeting method will rarely provide the results you desire.Consider the",title:"Mastering Your Market with Customer Personas",url:"https://cleandigital.co.uk/blog/mastering-your-market-with-customer-personas"}],secondaryKeywords:[],seoDescription:'Automate image "Color" attribute with Python. Work at an eCommere brand? Weâve outlined a way to automate the process and have the attributes ready in seconds.',seoTitle:"Colourful Solutions: Automate Image âColorâ Attribute With Python",shareUrl:"https://cleandigital.co.uk/blog/automate-image-color",slug:"automate-image-color",status:"published",summary:"We all know how important it is to have a healthy feed full of attributes that allows Google to perform better by improving matching relevancy. However,",title:"Colourful Solutions: Automate Image âColorâ Attribute With Python",url:"https://cleandigital.co.uk/blog/automate-image-color",visibility:"public"},f=()=>e.createElement(t,{initialPostData:a});export{f as Component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.