A little background regarding carmine:
The dye (Carmine) originates from the cochineal (a scale insect). These insects are bred and harvested solely for the production of the dye. The insects live on cacti and they have to be harvested and killed by boiling, sunlight, steam or the heat from an oven. Each method produces a different intensity or variation in the colour of the dye. The insects are then dried to 30% of their body weight and then thrown into an ammonia solution where they are boiled. The solution is then strained for insoluble parts. Alum is added to the strained solution to arrive at what is known as carminic acid or carmine.
Carmine is used as a food dye as well as a dye found in most cosmetics. Most of the opinions I have come across so far state that carmine is haraam insofar as consumption is concerned. The problem occurs with application of the product.
I’m struggling to understand the reasoning behind the permissibility granted for application purposes. But if it is permissible in application and the product is in itself ‘pure’ for application purposes, the only other method which I can think of to prove that buying a product containing carmine is haraam is to prove that the process of making the actual carmine is haraam in the first place.
The idea behind it lies in a fatwa from Deoband about mangoes which were sold prior to ripening. The initial sale was haraam and therefore people were told not to buy the mangoes coming from this specific town or area because it would be haraam to buy it. The distinction lies in the fact that mangoes did not become haraam but buying these specific mangoes became haraam.
So these insects are bred for killing basically… Is there a concept or rule in Islam where one cannot breed ants to kill them? I think it specifically mentions ants as an example. The loophole which may be used is that the ants are being bred and killed to extract some kind of medicine or something which may have a medicinal use but can only be extracted in this way. If I were to apply this analogy to the making of carmine, then would the process of making carmine be haraam? Currently there are no medicinal benefits of carmine listed anywhere other than the fact that it is more ‘natural’ to use as a dye than synthetic dyes. If the analogy is correct and the loophole for ‘medicinal benefit’ does not exist, then would it not be haraam for the manufacturer to purchase the carmine from the supplier? And then would it also be haraam for the average person to purchase any products containing carmine in it? (Using the analogy of the fatwa for mangoes).
So in this way, the explanation that carmine is halaal or permissible for application stands unaffected BUT the process used to make carmine is haraam in the first place and renders the purchasing of carmine down the chain also haraam. It may be a long-winded view or very technical but at this moment in time I cannot think of any examples currently in use today where something similar occurs and it is clearly stated as permissible for application. Other insects such as bees, silk worms etc. are not killed for their by-products as is the case of the cochineal where it is being bred to kill.
With regard to the loophole, I would just like to add that I cannot find any reasoning that would define ‘makeup’ or cosmetics as ‘necessary’. Perhaps in the case of foundation, one could argue that if a lady has an unsightly scar and the only foundation that would be able to hide it is a foundation containing carmine, then maybe in that particular case, permissibility would be granted BUT it would be only for that specific case. The carmine is just a dye meaning it’s only used to create the colour required for the product. It has no other purpose besides this.
I would really appreciate any assistance in this regard & JazakAllahu khayr for all assistance rendered so far.
In the Name of Allah, the Most Gracious, the Most Merciful.
As-salāmu ‘alaykum wa-rahmatullāhi wa-barakātuh.
Consuming carmine is impermissible due to the fact that the intake of insects is prohibited.  The external application of carmine is permissible because the cochineal insect is not impure.  In fact, the Jurists have even permitted the sale of insects as long as they possess value in the market and are used by people. 
According to Sharīah, it is not prohibited to kill insects to derive benefit from them.  It is similar to slaughtering cattle and sheep. However, any inhumane way of killing cannot be condoned.
The example of the mangoes given in the query is non-analogous to carmine. The original transaction of the mangoes was invalid. The supermarkets never attained ownership of the mangoes. Therefore to purchase an item from someone who is not the owner is not permissible.
In brief, the prohibition in the case of mangoes was due to an external and overarching prohibition expressly stated in the Hadīth. That is not the case with insects.
And Allah Ta’āla Knows Best
Mawlana Abdul Azīm bin Abdur Rahman,
Student Darul Iftaa
Checked and Approved by,
Mufti Ebrahim Desai.
 الهداية، ج 4، ص 102، دار الفرفور
 (قوله: وقمل وبرغوث وبق) أي: وإن كثر بحر ومنية. وفيه تعريض بما عن بعض الشافعية أنه لا يعفى عن الكثير منه، وشمل ما كان في البدن والثوب تعمد إصابته أو لا. اهـ. حلية، وعليه فلو قتل القمل في ثوبه يعفى عنه، وتمامه في الحلية. ولو ألقاه في زيت ونحوه لا ينجسه لما مر في كتاب الطهارة من أن موت ما لا نفس له سائلة في الإناء لا ينجسه.(رد المحتار، ج 1، ص 320، سعيد)
 ويجوز بيع سائر الحيوانات سوى الخنزير وهو المختار (رد المحتار، ج 5، ص 69، سعيد)
امداد الاحكام، ج 3، ص 390، مكتبة دار العلوم كراتشي
 والحشرات هل يباح في الشرع ابتداء من غير إيذاء وهل يثاب على قتلهم؟ قال لا يثاب على ذلك وإن لم يوجد منه الإيذاء فالأولى أن لا يتعرض بقتل شيء منه كذا في جواهر الفتاوى. (الهندية، ج 5، ص 361)